Gayner Posted November 21, 2009 Share Posted November 21, 2009 Notice: Undefined index: msg in C:\wamp\www\index.php on line 54 LINE 54: if ($_GET['msg']) { } else { } Why? I just moved to my localhost, these error's never popped up on my hosting ? Quote Link to comment https://forums.phpfreaks.com/topic/182431-notice-undefined-index-msg-i/ Share on other sites More sharing options...
cags Posted November 21, 2009 Share Posted November 21, 2009 Because your localhost has error_reporting set to E_STRICT whereas your hosting is probably set to everything except notices. It's a very low level error, it means you are trying to access the item 'msg' in the $_GET array, but there isn't one. You should be doing... if(isset($_GET['msg'])) { // do something } else { // do something else } Quote Link to comment https://forums.phpfreaks.com/topic/182431-notice-undefined-index-msg-i/#findComment-962753 Share on other sites More sharing options...
Gayner Posted November 21, 2009 Author Share Posted November 21, 2009 Because your localhost has error_reporting set to E_STRICT whereas your hosting is probably set to everything except notices. It's a very low level error, it means you are trying to access the item 'msg' in the $_GET array, but there isn't one. You should be doing... if(isset($_GET['msg'])) { // do something } else { // do something else } Wat the hell does isset do? Quote Link to comment https://forums.phpfreaks.com/topic/182431-notice-undefined-index-msg-i/#findComment-962760 Share on other sites More sharing options...
Alex Posted November 21, 2009 Share Posted November 21, 2009 Check the manual, isset. Simply put it allows you to check if a variable is..well set without throwing a notice if it isn't. Quote Link to comment https://forums.phpfreaks.com/topic/182431-notice-undefined-index-msg-i/#findComment-962761 Share on other sites More sharing options...
waynew Posted November 21, 2009 Share Posted November 21, 2009 isset() returns true if the value you're giving it actually exists. If the value doesn't exist, it returns false. Quote Link to comment https://forums.phpfreaks.com/topic/182431-notice-undefined-index-msg-i/#findComment-962762 Share on other sites More sharing options...
Gayner Posted November 21, 2009 Author Share Posted November 21, 2009 isset() returns true if the value you're giving it actually exists. If the value doesn't exist, it returns false. Why php add these values? just use = true on the $_GET instead of making it all complicated like this? im out Quote Link to comment https://forums.phpfreaks.com/topic/182431-notice-undefined-index-msg-i/#findComment-962771 Share on other sites More sharing options...
cags Posted November 21, 2009 Share Posted November 21, 2009 Because if you want to store FALSE in a variable, thats not the same as NULL, ie not having a value. Quote Link to comment https://forums.phpfreaks.com/topic/182431-notice-undefined-index-msg-i/#findComment-962772 Share on other sites More sharing options...
Gayner Posted November 21, 2009 Author Share Posted November 21, 2009 Because if you want to store FALSE in a variable, thats not the same as NULL, ie not having a value. Ok thx Quote Link to comment https://forums.phpfreaks.com/topic/182431-notice-undefined-index-msg-i/#findComment-962778 Share on other sites More sharing options...
Daniel0 Posted November 21, 2009 Share Posted November 21, 2009 Because your localhost has error_reporting set to E_STRICT whereas your hosting is probably set to everything except notices. Notices aren't affected by E_STRICT, but E_NOTICE. Quote Link to comment https://forums.phpfreaks.com/topic/182431-notice-undefined-index-msg-i/#findComment-962785 Share on other sites More sharing options...
cags Posted November 21, 2009 Share Posted November 21, 2009 Because your localhost has error_reporting set to E_STRICT whereas your hosting is probably set to everything except notices. Notices aren't affected by E_STRICT, but E_NOTICE. Oops, quite right, I meant E_ALL. Quote Link to comment https://forums.phpfreaks.com/topic/182431-notice-undefined-index-msg-i/#findComment-962789 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.