stevenreid Posted October 3, 2008 Share Posted October 3, 2008 i've used the following code in the past if ($_REQUEST["newsstory"] != ""){ $row = $_REQUEST["newsstory"]; }else{ $row = $lastNews; } The server the site was on has been updated to version 5.1.6 from 4.3.9 and now I get a whole lot of errors. newsstory is a querystring, previously it was just a case of - if the querystring is blank, use this variable instead (which is defined earlier on). So I'm wondering if there's a way to fix this. I'm really not knowledgeable in PHP, so sorry if the fix seems like it's something obvious. at the moment I'm using error_reporting(0); and everything works fine on the surface, but of course I'd like to know how to have it work properly. Cheers. Quote Link to comment Share on other sites More sharing options...
aebstract Posted October 3, 2008 Share Posted October 3, 2008 You said you had a lot of errors? What errors are you getting? Can you post them? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 3, 2008 Share Posted October 3, 2008 Those errors were always present in your code but the error_reporting or display_errors setting was causing them to be hidden. The reason for the error in the code you posted is because the code is referencing the value of a variable when that variable does not exist. The correct way to perform that logic is to use the isset() function. The isset() function checks if the variable exists without referencing its' value and no error is generated when the variable does not exist. On a live server, the display_errors setting should be OFF and on a development system it should be ON. error_reporting should always be set to at least E_ALL so that actual errors that occur are logged and you have a record of problems, like a hacker feeding your script unexpected and invalid data that triggers errors in an attempt to break into your script. Quote Link to comment Share on other sites More sharing options...
stevenreid Posted October 3, 2008 Author Share Posted October 3, 2008 fantastic - another little bit of PHP I've learned about, cheers. Quote Link to comment 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.