Jump to content
  • Advertisement
Sign in to follow this  
chbrules

[PHP] Issue w/ GET Variables

This topic is 4819 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Whenever I try to read a get variable while it's not in the URL it gives me a warning:
Notice: Undefined index: check in \xxxxxx\xxxxxx.php on line 11
Line 11 is:
$check = $_GET['check'];
I'm guessing it's some debug feature in PHP I haven't turned off on my server? I remember I used to be able to try to read it, if it isn't there then it'd be NULL and I'd do a check against it. Now I get stupid errors. =/ I'm using IIS w/ PHP 5. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Rob Loach
I haven't had much experiance with PHP5, but I do know that register_globals can mess around with some stuff. You could check the documentation (I'm assuming you already have).


register_globals would have made the 'check' GET variable $check automatically.

The reason you're getting an index undefined error is because $_GET is an array. An associative array of key=value pairs that comes from your GET arguments. If the key "check" is not on the url, then it will not be in the array and thus the index in the array is undefined.

You will need to test it first..
$check=some default value;
if(isset($_GET['check']))
$check = $_GET['check'];

Share this post


Link to post
Share on other sites
That's right..., with PHP 4 that didn't happened but now PHP 5 compains about it....

Share this post


Link to post
Share on other sites
Quote:
Original post by haora
That's right..., with PHP 4 that didn't happened but now PHP 5 compains about it....


It could be the php.ini settings in 5 are slightly different. Check the "Error handling and logging" section in your php.ini file.. It contains decent documentation on how to change the settings for the error_reporting and display_errors settings.

Share this post


Link to post
Share on other sites
Anyone know specifically how to shut it off or am I going hunting? I'll try that isset() check. Thanks!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!