chanchelkumar Posted June 14, 2008 Share Posted June 14, 2008 Hi all, I installed php and i it's running ok... But while am using a null variable am getting this error Notice: Undefined index: What is this?? How could i chage this... Thanks in advance... Quote Link to comment https://forums.phpfreaks.com/topic/110177-getting-this-error-notice-undefined-index/ Share on other sites More sharing options...
corbin Posted June 14, 2008 Share Posted June 14, 2008 This has nothing to do with the installation fo WAMP.... Anyway.... What it means is that a referenced index of an array does not exist. The following code, for example, would generate an error: <?php $a = array('str1' => 'Hello', 'str2' => 'World'); //all of these would throw notices echo $a['str3']; echo $a[2]; echo $a['omgwhatisthis']; ?> The way around it? isset() (or if you need to check the existance even of null values, array_key_exists()). Example: if(isset($a[$var])) echo $a[$var]; if(array_key_exists($var, $a)) echo $a[$var]; Quote Link to comment https://forums.phpfreaks.com/topic/110177-getting-this-error-notice-undefined-index/#findComment-565432 Share on other sites More sharing options...
chanchelkumar Posted June 14, 2008 Author Share Posted June 14, 2008 Hi, Thanks for your reply... But my another machine is not showing this error.... Same Windows 2003 server.. Same code produces Error in one machine and not showing this error in other machine... That's why i confused about installation... Any other way ??? Quote Link to comment https://forums.phpfreaks.com/topic/110177-getting-this-error-notice-undefined-index/#findComment-565454 Share on other sites More sharing options...
wildteen88 Posted June 14, 2008 Share Posted June 14, 2008 The other machine most probably has display_errors disabled or error_reporting is set to ignore notices, this is why you dont get the underfined index message displayed. This also does not mean that your code is running fine on the other machine as no errors are displayed, they will be logged in your servers error log though. Quote Link to comment https://forums.phpfreaks.com/topic/110177-getting-this-error-notice-undefined-index/#findComment-565477 Share on other sites More sharing options...
chanchelkumar Posted June 18, 2008 Author Share Posted June 18, 2008 Thanks wildteen... But, how do i turn this on/off ?? i think i can check it through phpinfo() I got it as error_reporting=6135 and display_errors=on in my no problem machine.... Quote Link to comment https://forums.phpfreaks.com/topic/110177-getting-this-error-notice-undefined-index/#findComment-567821 Share on other sites More sharing options...
PFMaBiSmAd Posted June 18, 2008 Share Posted June 18, 2008 There are other settings, such as register_globals or even short open tags that could cause data to exist or code to be parsed on one server and not another. You would need to post the code that is generating the error and the whole error message to get specific help with your problem. Quote Link to comment https://forums.phpfreaks.com/topic/110177-getting-this-error-notice-undefined-index/#findComment-568168 Share on other sites More sharing options...
vijrohit Posted June 22, 2008 Share Posted June 22, 2008 hi Kumar, though posting the code snippet here will get you the exact solution to this problem but in the mean time please try this:- set error_reporting=6143 in php.ini and then restart you wamp server and check the same code in your no problem machine.This will show you the error on your second machine also and then post the code snippet in order to get the correct solution for it or you can just turn off the notices on both the machines by setting error_reporting=1, which is not recomended idealy. Best of Luck RV Quote Link to comment https://forums.phpfreaks.com/topic/110177-getting-this-error-notice-undefined-index/#findComment-571347 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.