Jump to content

Help with broken PHP pages after server upgrade


damion

Recommended Posts

I have 2 pages in my flash site that call some PHP files. The pages are a feedback page and a locator page. When my server went from PHP4 to PHP5 both pages stopped displaying the content. When I load the flash pages with Fiddler open, fiddler shows a 500 error on the PHP files that the flash is calling. I'm certain my database connections are good, file paths have not changed since the server maintenance, and I have .htaccess files except they are blank.

 

Can anyone advise what I can do to find where the problem is? I have the PHP code below that showed the 500 errors. Any help would be really appreciated.

 

This is the locator page:

<?php
include_once('db_connect.inc.php');


	$query = "SELECT state FROM stores group BY state ORDER BY state";

	$result = mysql_query($query);	



if(mysql_num_rows($result)==NULL){

	$r_string = '&error=1&msg=No Records Found.';

}else{

	$r_string = '&error=0&n='.mysql_num_rows($result) . '&r_states=';
	  
  $i = 0;
  $r='';
      while ($row = mysql_fetch_assoc($result)) {
  		if($r!='') $r .= '||';
            $r .= $row['state'];
         $i++;
      }
  $r_string .= $r;
      // add extra & to prevent returning extra chars at the end
      $r_string .='&';
  
  
  }
  
   
echo $r_string;
?>

 

This is the feedback page:

<?php
	include_once('inc/feedbackconn.inc.php');

	echo '&rsult=';
	$query = "SELECT * FROM messages where active!=0";
	$result = mysql_query($query);
	$num = @mysql_num_rows($result);
	$cfeed=$_POST['sFeed'];
	$cfeed--;
	$query = "SELECT * FROM messages where active='1' ORDER BY id LIMIT " . $cfeed . ',1';
	$result = mysql_query($query);
	//$row = mysql_fetch_array($result);

	if($num==NULL){

	echo "No Records.";
	exit();
	}

 while($row = @mysql_fetch_array($result)){

      $b_name = stripslashes($row[strName]);
      $b_loc = stripslashes($row[strLocation]);
      $b_mes = stripslashes($row[strMessage]);
	  $b_id = $row[id];
	  $b_active = $row[active];

      $feedArray[] = array("name"=>$b_name,"location"=>$b_loc,"feedback"=>$b_mes,"id"=>$b_id,"active"=>$b_active);

      }



/* /////////////// DISPLAY THE RECORDS ///////////////// */
$numOfMessages = sizeOf($feedArray);

for($i=0;$i<$numOfMessages;$i++){


//------------------------------------------------------------------
    //echo $feedArray[$i]['id']."<br>\n";
	echo '<b><i>' . $feedArray[$i]['feedback']."</i><br><br>";
	echo $feedArray[$i]['name']."<br>";
	echo $feedArray[$i]['location']."</b>";
//---------------------------------------------------------------------
}
echo '&tFeeds=' . $num;	
echo '&cFeed=' . $_POST['sFeed'];
?>

 

Link to comment
Share on other sites

Add the following two lines of code immediately after the first opening <?php tag to get php to report and display all the runtime errors it detects -

 

ini_set("display_errors", "1");
error_reporting(-1);

 

Also, if you browse directly to the .php pages, it will be easer to see the actual output and debug whatever is going on.

 

Link to comment
Share on other sites

Add the following two lines of code immediately after the first opening <?php tag to get php to report and display all the runtime errors it detects -

 

ini_set("display_errors", "1");
error_reporting(-1);

 

Also, if you browse directly to the .php pages, it will be easer to see the actual output and debug whatever is going on.

 

Thanks. Adding those lines do not do anything. It might be because the pages are flash and cannot display them, I'm not sure. But with or without those lines inside the files, I get an internal server error when I try to load them in my browser directly. Here is my error log, hopefully there are clues here?

 

[Thu Feb 23 21:23:21 2012] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/me/public_html/500.shtml

[Thu Feb 23 21:23:21 2012] [alert] [client xxx.xxx.xxx.xxx] /home/me/public_html/mysite/php/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration

 

Link to comment
Share on other sites

.htaccess: Invalid command 'php_value'

 

^^^ You can only put php settings in a .htaccess file when php is running as a server module. It is highly likely that php is now running as a CGI application.

 

Start by removing or commenting out any php settings in your .htaccess file and see what you get.

Link to comment
Share on other sites

Wow! I checked that file at least a half a dozen times, and I swear it was blank. I even used cpanel's file manager as well to be certain nothing was cached locally, and still blank. Then I decided to rename the file and wham, the locator page worked. So Thanks!

 

Now the other page (the feedback page) is also coming to life. It is now displaying an error because of those lines you had me put in place at the beginning. The error is:

Notice:  Undefined variable: feedArray in /home/me/public_html/mysite/php/getfeedbacks.php on line 37

 

The file is what I posted above and line 37 is this one:

/* /////////////// DISPLAY THE RECORDS ///////////////// */
$numOfMessages = sizeOf($feedArray);

 

Can you offer anymore magic?

 

 

Link to comment
Share on other sites

Remove the two @'s (error suppressor operator) that are in front of the mysql_ statements in that code. If your queries are failing due to an error of some kind, you would want to know that (or let php log the errors in the error log file.) The @ error suppressor prevents the display or logging of php detected errors that might be occurring in the statements it is in front of.

Link to comment
Share on other sites

Okay, more progress made. I can see the data from one of the table rows (strLocation). And also all of the messages below.

 

Notice:  Use of undefined constant strName - assumed 'strName' in /home/me/public_html/mysite/php/getfeedbacks.php on line 24
Notice:  Use of undefined constant strLocation - assumed 'strLocation' in /home/me/public_html/mysite/php/getfeedbacks.php on line 25
Notice:  Use of undefined constant strMessage - assumed 'strMessage' in /home/me/public_html/mysite/php/getfeedbacks.php on line 26
Notice:  Use of undefined constant id - assumed 'id' in /home/me/public_html/mysite/php/getfeedbacks.php on line 27
Notice:  Use of undefined constant active - assumed 'active' in /home/me/public_html/mysite/php/getfeedbacks.php on line 28

 

Doing a search on those notices, I saw that someone resolved them by putting quotes around their array keys. I tried that and and it did remove the notices, but all except for that one data row were still missing.

 

Thanks

Link to comment
Share on other sites

I'm getting closer.

 

I put echo statements in the above PHP file in random spots and I determined that the first line below is not outputting anything.

 

echo '<b><i>' . $feedArray[$i]['feedback']."</i><br><br>";
	echo $feedArray[$i]['name']."<br>";
	echo $feedArray[$i]['location']."</b>";

 

Any ideas? Almost there.

Link to comment
Share on other sites

Try doing a var_dump($feedArray) right before that line to see if there is an actual value for 'feedback'.

 

Yes. I added that line and it did output the missing data. However, the text was missing missing some letters and was sort of jibberish. But there.

Link to comment
Share on other sites

Sure! (I changed the name to protect the innocent)

 

array(5) {

  ["name"]=>

  string(17) "Jeff Smith"

  ["location"]=>

  string(12) "Woodland, CA"

  ["feedback"]=>

  string(52) "I love your work! Keep it up!"

  ["id"]=>

  string(2) "12"

  ["active"]=>

  string(1) "1"

 

And this is what I used. I commented out the rest of the lines.

	    //echo $feedArray[$i]['id']."<br>\n";
	var_dump($feedArray[$i]);
         /*	echo '<b><i>' . $feedArray[$i]['feedback']."</i><br><br>";
	echo $feedArray[$i]['name']."<br>";
	echo $feedArray[$i]['location']."</b>"; 
          */

Link to comment
Share on other sites

Okay, get this. I focused on the line that was not outputting the data. So out of desperation and hoping for some luck I tried replacing single quotes for double quotes, <br /> for <br>, and anything else that can be substituted by an equivalent method. If you can see the difference below, then yup..that made the difference and fixed it. If someone can explain why it fixed it, I'm all ears.

 

Before:

echo '<b><i>' . $feedArray[$i]['feedback'] . "</i><br><br>";

 

After:

echo '<b><em>' . $feedArray[$i]['feedback'] . "</em><br><br>";

 

Special thanks to batwimp and PFMaBiSmAd for your time and help.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.