xFalseProphet Posted August 19, 2014 Share Posted August 19, 2014 Hello! This may sound like a stupid question but i have been trying to get this working all day and its driving me crazy. Ive been asked to take over development of this project, he sent me his code and its a little out of date so im trying to update it. Here is what i cant work out. I have this little snippet of code: if ($page == "showthread"){ showThread(); } There are several more like that, but you dont need a whole list. That code seems to be throwing up this error when i go to that specific page: Notice: Undefined index: error in ..... All well and good, i would usually do this: if (isset($page) == "showthread"){ showThread(); } Thats fine and dandy, the error goes away. But now, when i go to that page, it redirects me and gives me my error message for a non-existing page. Its really frustrating me. Can you help me fix this little error? Quote Link to comment https://forums.phpfreaks.com/topic/290528-why-isnt-isset-working-whats-wrong-with-this/ Share on other sites More sharing options...
trq Posted August 19, 2014 Share Posted August 19, 2014 isset returns a boolean true or false, so its result will never equal the string "showthread". On top of that, I fail to see how that could possibly have fixed your error. Can you post the original and complete error message? Quote Link to comment https://forums.phpfreaks.com/topic/290528-why-isnt-isset-working-whats-wrong-with-this/#findComment-1488257 Share on other sites More sharing options...
xFalseProphet Posted August 19, 2014 Author Share Posted August 19, 2014 Ok i read the errors wrong, they were only showing 'Undefined index: page in...' when there was no page=xxx in the url. Im not sure how to fix that, have you any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/290528-why-isnt-isset-working-whats-wrong-with-this/#findComment-1488260 Share on other sites More sharing options...
Solution trq Posted August 19, 2014 Solution Share Posted August 19, 2014 Yes, you would fix that by checking the index exists (using isset) within the array before accessing it. Quote Link to comment https://forums.phpfreaks.com/topic/290528-why-isnt-isset-working-whats-wrong-with-this/#findComment-1488262 Share on other sites More sharing options...
xFalseProphet Posted August 20, 2014 Author Share Posted August 20, 2014 I fixed it. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/290528-why-isnt-isset-working-whats-wrong-with-this/#findComment-1488375 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.