damion Posted February 24, 2012 Share Posted February 24, 2012 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']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/257666-help-with-broken-php-pages-after-server-upgrade/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 24, 2012 Share Posted February 24, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/257666-help-with-broken-php-pages-after-server-upgrade/#findComment-1320661 Share on other sites More sharing options...
damion Posted February 24, 2012 Author Share Posted February 24, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/257666-help-with-broken-php-pages-after-server-upgrade/#findComment-1320668 Share on other sites More sharing options...
PFMaBiSmAd Posted February 24, 2012 Share Posted February 24, 2012 .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. Quote Link to comment https://forums.phpfreaks.com/topic/257666-help-with-broken-php-pages-after-server-upgrade/#findComment-1320671 Share on other sites More sharing options...
damion Posted February 24, 2012 Author Share Posted February 24, 2012 My only .htaccess files are blank. Quote Link to comment https://forums.phpfreaks.com/topic/257666-help-with-broken-php-pages-after-server-upgrade/#findComment-1320675 Share on other sites More sharing options...
PFMaBiSmAd Posted February 24, 2012 Share Posted February 24, 2012 The one that is in /home/me/public_html/mysite/php/ isn't or you would not be getting that error. Quote Link to comment https://forums.phpfreaks.com/topic/257666-help-with-broken-php-pages-after-server-upgrade/#findComment-1320683 Share on other sites More sharing options...
damion Posted February 24, 2012 Author Share Posted February 24, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/257666-help-with-broken-php-pages-after-server-upgrade/#findComment-1320696 Share on other sites More sharing options...
PFMaBiSmAd Posted February 24, 2012 Share Posted February 24, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/257666-help-with-broken-php-pages-after-server-upgrade/#findComment-1320773 Share on other sites More sharing options...
damion Posted February 24, 2012 Author Share Posted February 24, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/257666-help-with-broken-php-pages-after-server-upgrade/#findComment-1320826 Share on other sites More sharing options...
damion Posted February 24, 2012 Author Share Posted February 24, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/257666-help-with-broken-php-pages-after-server-upgrade/#findComment-1320883 Share on other sites More sharing options...
batwimp Posted February 24, 2012 Share Posted February 24, 2012 Try doing a var_dump($feedArray) right before that line to see if there is an actual value for 'feedback'. Quote Link to comment https://forums.phpfreaks.com/topic/257666-help-with-broken-php-pages-after-server-upgrade/#findComment-1320931 Share on other sites More sharing options...
damion Posted February 24, 2012 Author Share Posted February 24, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/257666-help-with-broken-php-pages-after-server-upgrade/#findComment-1320940 Share on other sites More sharing options...
batwimp Posted February 24, 2012 Share Posted February 24, 2012 Sorry, I meant var_dump($feedArray[$i]) to see if there is anything there. Quote Link to comment https://forums.phpfreaks.com/topic/257666-help-with-broken-php-pages-after-server-upgrade/#findComment-1320955 Share on other sites More sharing options...
damion Posted February 24, 2012 Author Share Posted February 24, 2012 It's cool. Yeah, same thing got output. The second one just looks like it is an array within an array if that makes sense. So this proves the variable is holding the missing data. That's good, right? Quote Link to comment https://forums.phpfreaks.com/topic/257666-help-with-broken-php-pages-after-server-upgrade/#findComment-1320960 Share on other sites More sharing options...
batwimp Posted February 24, 2012 Share Posted February 24, 2012 Can you post the output here? Also post the var_dump statement you used to get the output. Quote Link to comment https://forums.phpfreaks.com/topic/257666-help-with-broken-php-pages-after-server-upgrade/#findComment-1320961 Share on other sites More sharing options...
damion Posted February 24, 2012 Author Share Posted February 24, 2012 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>"; */ Quote Link to comment https://forums.phpfreaks.com/topic/257666-help-with-broken-php-pages-after-server-upgrade/#findComment-1320963 Share on other sites More sharing options...
batwimp Posted February 24, 2012 Share Posted February 24, 2012 I can't think of any reason this wouldn't be printing out. I'll keep thinking. Quote Link to comment https://forums.phpfreaks.com/topic/257666-help-with-broken-php-pages-after-server-upgrade/#findComment-1320964 Share on other sites More sharing options...
damion Posted February 24, 2012 Author Share Posted February 24, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/257666-help-with-broken-php-pages-after-server-upgrade/#findComment-1320972 Share on other sites More sharing options...
batwimp Posted February 25, 2012 Share Posted February 25, 2012 I thought about that, too. But I loaded up your code on my server and created a little array for it to load up, and it worked just fine with your original code. Very odd. Quote Link to comment https://forums.phpfreaks.com/topic/257666-help-with-broken-php-pages-after-server-upgrade/#findComment-1320973 Share on other sites More sharing options...
damion Posted February 25, 2012 Author Share Posted February 25, 2012 Now I'm scared to test the submission part of the application (you might see me again real soon!) Well here goes nuthin... Quote Link to comment https://forums.phpfreaks.com/topic/257666-help-with-broken-php-pages-after-server-upgrade/#findComment-1320974 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.