Web Hosting Forum | Lunarpages

Author Topic: PHP 5.3 upgrade gave me WSOD  (Read 5519 times)

Offline Jeff

  • Space Explorer
  • ***
  • Posts: 7
PHP 5.3 upgrade gave me WSOD
« on: December 03, 2015, 07:29:35 PM »
Hello everyone, I'm not an expert with php and have a site I host for a friend that I need help. The site came up all blank a little over a month ago and I have been trying to figure this out myself but need professional help!!! The previous version according to LP was php4 and the upgraded version in control panel shows native (php5.3). LP says they can have their developer build a new site because the current website is too old to fix but I think I need to update the code to make it work.

I have looked online and on LP forums on upgrade changes I need to make on the php code and some point to changing syntax to mysqli. I also found I needed to change the htaccess file and have tried many things but nothing has worked so far.   

Any help or direction would be greatly appreciated.
Thanks

Offline Jeff

  • Space Explorer
  • ***
  • Posts: 7
Re: PHP 5.3 upgrade gave me WSOD
« Reply #1 on: December 03, 2015, 08:28:24 PM »
This is the php code from the index.php page.

<?php
   
 
session_start();
include("common.php");

$Manager = new Manager;

   $Manager->log_domain($AGENT,$ADMIN,$count_domain);

   if ($home){
      $Manager->create_header($link,"","",$biz_row[BizName],$domain,$templates);
   }
   else {
      $Manager->create_header($link,$AGENT,$ADMIN,$biz_row[BizName],$domain,$templates);
   }


   if ($action == "agent_display" or $agent_display){
      if ($agentnum) $ID = $agentnum;
      if ($agent_display) $ID = $agent_display;
      $Manager->create_generic_page($link,$domain,$templates,'NoContentNoFeatured');
      $Manager->create_agent_display ($link,$ID,$domain,$templates);
      echo $Manager->end_generic();
   }

   else {
      
      $Manager->create_generic_page($link,$domain,$templates,'NoContent');

?>

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6208
Re: PHP 5.3 upgrade gave me WSOD
« Reply #2 on: December 04, 2015, 05:35:16 AM »
Very few sites break at PHP 5.3, unless they are absolutely ancient code, but quite a few start breaking at PHP 5.4 and above. Unlike many other languages and systems, the folks at PHP seem to take a perverse pride in breaking existing code with their updates (i.e., for better or worse they make no effort to be backwards compatible). Your friend is paying the price for not keeping their site code reasonably updated.

Now, is this custom-written code or is it an off-the-shelf (canned) application? If the latter, the easiest path might be to upgrade to the current version (if available), or switch to another application that is current. If it's custom, someone proficient in PHP needs to be maintaining the site. Because PHP always breaks old code, this can't be left to casual chance.

If you're getting an error message or logged entry, what error is it? http://www.catskilltech.com/freeSW/SMF/faqs/index.html#err500 lists many causes for a 500 error. They're quite common when PHP is upgraded, so make sure you aren't overlooking a 500 error in your log. If it's truly the White Screen of Death, look at http://www.catskilltech.com/freeSW/SMF/faqs/index.html#wsod for debugging guidance. It's almost always a PHP syntax error, where something that was acceptable code before is now forbidden.
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

Offline scanman20

  • Senior Moderator
  • Über Jedi
  • *****
  • Posts: 1550
    • http://www.notonebit.com
Re: PHP 5.3 upgrade gave me WSOD
« Reply #3 on: December 04, 2015, 06:48:59 AM »
Your account's error logs should shed some light on the issue.
Even a broken clock is right twice a day.
NotOneBit.com
MCSE - MCSA - MCP (<- unused since 2006!)

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6208
Re: PHP 5.3 upgrade gave me WSOD
« Reply #4 on: December 04, 2015, 07:00:03 AM »
You are missing a closing } before the ?>. Try adding it in. Otherwise, there's nothing in the code you listed that jumps out at me as an obvious syntax error. Maybe there's something fairly subtle going on. I think the next step is to see if it's actually failing within this file, or in one of the method calls. What's in common.php? Does it define the Manager class? You could try inserting an "I am here" print/echo line by line, until you find the last place that the code gets to before going south. Note that output to the browser before the session_start() will probably cause a "headers cannot be modified" error. If any of the methods also set HTTP headers, you will also get that error.

Also check for obvious things like a blank/empty line before the opening <?php or after the closing ?>. That should normally give a 500 error, and probably would have shown up under the older PHP. Was the file edited recently?
« Last Edit: December 04, 2015, 07:04:39 AM by MrPhil »
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

Offline Jeff

  • Space Explorer
  • ***
  • Posts: 7
Re: PHP 5.3 upgrade gave me WSOD
« Reply #5 on: December 05, 2015, 09:06:09 PM »
I added the missing } before the ?> but didn't help. This site was built by someone and is not something I can upgrade the version (I wish I could). But, with or without the } added in the page now actually downloads instead of coming up as the WSOD. All the php code and HTML code is in the downloaded file. I tried this in Google Chrome but the Windows 10 browser shows the old redirect I had setup. I had the page redirecting to my friends facebook page until I was able to fix the site.

Before I wasn't getting any errors just a blank white screen and nothing in the source code except opening and closing HTML tags. The file wasn't edited by anyone. Common.php is the main configuration file used for setting global variables and has the DB, user name, password, etc in there. I also know it had MySQL which I believe needs to be updated to mysqli in the current version.

But, since the page is currently not coming up and instead is downloading I'm not sure what's going on. The site is tierramiarealty.com and I will keep the redirect off if anyone has a chance to take a look and give me and idea what to troubleshoot. And, in the meantime I will work on what is causing this to occur.

Thanks for anyone that can help and for those that responded to me I appreciate it.

Offline Jeff

  • Space Explorer
  • ***
  • Posts: 7
Re: PHP 5.3 upgrade gave me WSOD
« Reply #6 on: December 05, 2015, 09:37:43 PM »
Code: [Select]
OK, I'm finally getting somewhere. I searched the forums and double checked my htaccess file and changed it to:
AddHandler application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml
AddType application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml

Now I am NOT getting a download for my index.php file any longer. Now I get a "Couldn't connect to mySQL server" when pulling up the website which is the error in the common.php file that is set to display if MySQL can't connect. Here is the common.php code that I think is what I need to update/upgrade to make the connection.



<?php
// if you are having problems with expired pages, uncomment the line below
//session_cache_limiter('private');

// error reporting is turned off by default, uncomment and change to suit your needs
error_reporting(0);

// REGISTER GLOBALS OFF hack
// If your server has register globals set to OFF and you are having
// problems with sessions (not being able to log in), simply uncomment
// the lines of code below (remove the double // on each line) and it
// will work just the same.

$all array_merge($_GET,$_POST,$_SESSION);
if (is_array($all)){
                  foreach ($all as $key => $value){
  $$key $value;
}
 }

$db_user "********_tierram"// change this to your database username
$db_password "abc123"// change this to your database password
$db "********_relmdb"// change this to your database name
$server "localhost"// change this to your database server

$baseurl "http://morelandrealestate.com"// change this to the http root path to where RELM was installed


$link mysql_connect ($server$db_user$db_password);
if (! $link)
{
die ("Couldn't connect to mySQL server");
}
if (!mysql_select_db ($db$link) )
{
die ("Couldn't open $db: ".mysql_error() );
}


// Company Information
// This auto populates the company footer information
// The Company Name appears at the top of all web pages
// Found in the database table called "company"
$biz_q "select * from company";
$biz_r mysql_query($biz_q,$link);
$biz_row mysql_fetch_array($biz_r);

// number of properties per page
$properties_per_page 50;

// only controls how many upload forms appear on the Add Listing page
$picture_upload_max 5;

// only controls how many upload forms appear on the Agent page
$agent_upload_max 1;

// only controls how many upload forms appear on the Add Agent page
$agent_picture_upload_max 1;

// path the the fast template templates
$templates './templates';
$admin_templates './templates';

// main class and fast template includes
include("manager_class.php");
include(
"fast_template.php");


?>


<removed account name for security -- Mod>
« Last Edit: January 22, 2016, 03:11:40 PM by MrPhil »

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6208
Re: PHP 5.3 upgrade gave me WSOD
« Reply #7 on: December 06, 2015, 07:59:05 AM »
I think that the mysql_* extension is still supported by LP. You might run the following script
Code: [Select]
<?php phpinfo(); ?>and see if it lists MySQL (in addition to MySQLi). If MySQL is gone (I don't think it should be), you would have to upgrade the code to MySQLi (which you will have to do eventually). In most cases, it will probably be a matter of changing mysql_ to mysqli_, but there may be some other calls that have to be changed (parameter lists, etc.).

Did you have AddHandler and AddType entries before? Were they set to PHP4? Those shouldn't be necessary, as my understanding is that PHP5 is the default now. Maybe if PHP4 has disappeared, and your old entries pointed PHP files to PHP4, that might explain why you were getting the files downloaded and not run.

Register globals have long been turned off, so that tells me this is very old code.

It's not a good idea to expose your account name, and especially not to expose your password (I'll assume that you showed a made-up one). If that was your real password, change it right away! Also edit your post so that it hides your account name, if that's your real one.

Try adding that missing } after you have the AddHandler and AddType business sorted. It would be good to have it anyway, even if it runs (for now) without it.
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

Offline Jeff

  • Space Explorer
  • ***
  • Posts: 7
Re: PHP 5.3 upgrade gave me WSOD
« Reply #8 on: December 06, 2015, 09:37:27 PM »
I did a redirect for the website temporarily until I can get some time to check the mysqli extensions if I need it. I saw this in phpMyAdmin:

Web server
•cpsrvd 11.50.0.29
•Database client version: libmysql - 5.1.73
•PHP extension: mysqli

So I'm wondering if I need to change the code to mysqli instead of MySQL? Also, where do I run the script <?php phpinfo(); ?> you listed?
I also only had either the AddHandler or AddType entries before but since I've made different changes I didn't document which one was the only one in there. Since I'm getting the database connection errors and I changed the database password to try a different one without any luck I think I will check as you suggested the mysqli settings next. Thanks for the recommendation and if there was a php code checker I could use that would probably find what in the outdated code needs to be changed.

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6208
Re: PHP 5.3 upgrade gave me WSOD
« Reply #9 on: December 07, 2015, 05:58:34 AM »
You make a file (e.g., myinfo.php) with that one line in it, and run it from your browser. It will have sections for MySQL (if installed) and MySQLi (ditto). If there is no MySQL section (which would be surprising), you can ask LP if that was an oversight or deliberate. I don't recall seeing any announcements that MySQL would be dropped from builds, so it may be an oversight. If MySQL is gone for good from the PHP build, you will have to switch your code over to MySQLi. In most cases, it's a relatively small change (sometimes no more than changing the mysql_ prefix to mysqli_), but proceed carefully and slowly. Eventually you're going to have to do this on any server at any host, as the MySQL extension (for PHP) is being phased out in favor of MySQLi.

Note that you should never reveal the name of your phpinfo script to the public, and you should not publish the results in public. It contains information that might be useful to a hacker to break into your site.
« Last Edit: December 07, 2015, 06:02:18 AM by MrPhil »
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

Offline Jeff

  • Space Explorer
  • ***
  • Posts: 7
Re: PHP 5.3 upgrade gave me WSOD
« Reply #10 on: December 08, 2015, 07:08:32 PM »
Thanks for some direction on how to fix my issue. I will work on it the next few days and post how it goes.
Thanks again for helping I appreciate it.

Offline Jeff

  • Space Explorer
  • ***
  • Posts: 7
Re: PHP 5.3 upgrade gave me WSOD
« Reply #11 on: December 15, 2015, 09:15:51 PM »
I changed the code to mysqli instead of mysql but it didn't make a difference. I then changed the password "again" and now I get this error.
Couldn't open realtor_db:  which is the database name. Before the password change I was getting a "could not connect" error but now I'm connecting but get the couldn't open error.
I did a repair on the database but that didn't help. My next step is to search online at php.net to see if I can find a solution.
 

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6208
Re: PHP 5.3 upgrade gave me WSOD
« Reply #12 on: December 16, 2015, 05:34:25 AM »
Have you opened a support ticket to ask LP to confirm that your database server is up and running? Sometimes they go down and nothing is done until someone bothers to report the problem. If you have any other applications on your site that are successfully using the database, that would suggest that the DB is OK.

When you converted your code to MySQLi, I trust you did more than simply change the prefix from mysql_ to mysqli_? There are some changes to the parameter list that you need to make in many calls. Anyway, this change to MySQLi is not lost work -- it's something you will have to do anyway at some point in the near future, as MySQL will be removed from PHP.
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

 

Share |