s1yman Posted August 12, 2008 Share Posted August 12, 2008 Hi, I got this $pagenum = $_GET['pagenum']; //This checks to see if there is a page number. If not, it will set it to page 1 if (!(isset($pagenum))) { $pagenum = 1; } That should make sense, right? if there is no "pagenum" then it comes up with an error, I'm sure I used this script before without it telling me "Notice: Undefined index: pagenum in E:\location\index.php on line 190" any suggestions? Thanks Link to comment https://forums.phpfreaks.com/topic/119343-sure-this-should-work-already/ Share on other sites More sharing options...
dezkit Posted August 12, 2008 Share Posted August 12, 2008 if (!(isset($pagenum))) { $pagenum = 1; } else { $pagenum = 0; } Link to comment https://forums.phpfreaks.com/topic/119343-sure-this-should-work-already/#findComment-614779 Share on other sites More sharing options...
revraz Posted August 12, 2008 Share Posted August 12, 2008 Why would you want to set it to 0 if it's already set? Which line is 190? Link to comment https://forums.phpfreaks.com/topic/119343-sure-this-should-work-already/#findComment-614782 Share on other sites More sharing options...
efficacious Posted August 12, 2008 Share Posted August 12, 2008 should be like this //This checks to see if there is a page number. If not, it will set it to page 1 if (!(isset($pagenum))) { $pagenum = 1; } else { $pagenum = $_GET['pagenum']; } no sense in setting $pagenum = to $_GET['pagenum'] if you are just going to check if its set later on. Link to comment https://forums.phpfreaks.com/topic/119343-sure-this-should-work-already/#findComment-614803 Share on other sites More sharing options...
efficacious Posted August 12, 2008 Share Posted August 12, 2008 //This checks to see if there is a page number. If not, it will set it to page 1 if (!(isset($_GET['pagenum']))) { $pagenum = 1; } else { $pagenum = $_GET['pagenum']; } sory like this/\ Link to comment https://forums.phpfreaks.com/topic/119343-sure-this-should-work-already/#findComment-614809 Share on other sites More sharing options...
s1yman Posted August 12, 2008 Author Share Posted August 12, 2008 Which line is 190? line 190 is the top line $pagenum = $_GET['pagenum']; Link to comment https://forums.phpfreaks.com/topic/119343-sure-this-should-work-already/#findComment-614810 Share on other sites More sharing options...
revraz Posted August 12, 2008 Share Posted August 12, 2008 Yep, go with efficacious's suggestion. Link to comment https://forums.phpfreaks.com/topic/119343-sure-this-should-work-already/#findComment-614812 Share on other sites More sharing options...
s1yman Posted August 12, 2008 Author Share Posted August 12, 2008 That stopped the error but has now messed the rest of my script up ... 2secs Link to comment https://forums.phpfreaks.com/topic/119343-sure-this-should-work-already/#findComment-614820 Share on other sites More sharing options...
s1yman Posted August 12, 2008 Author Share Posted August 12, 2008 yeah, that doesn't make sense because you are saying (!(isset($pagenum))) before $pagenum is declared so it will never find it and therefore always set it to 1 (or am I chattin sh*t?) Link to comment https://forums.phpfreaks.com/topic/119343-sure-this-should-work-already/#findComment-614824 Share on other sites More sharing options...
efficacious Posted August 12, 2008 Share Posted August 12, 2008 actually it makes perfect sense you shouldn't be checking to see if $pagenum is set you should be checking to see if $_GET['pagenum'] is set because I'm assuming thats how you change your pages.. http://blah.com/?pagenum=2 if you keep it how you first posted.. then $pagenum will always be set.. cuz your setting it. $pagenum=$_GET['pagenum']; $pagenum now holds the value of $_GET['pagenum'] which holds the value sent over in the http address if you say if(!(isset($_GET['pagenum'])))//DID PAGENUM APPEAR IN HTTP URL? { $pagenum='1'; //IT DID NOT SO SET IT TO 1 } else { $pagenum=$_GET['pagenum']; //IT DID SO WE LEAVE IT TO EQUAL WHAT WAS SENT OVER IN THE URL } Link to comment https://forums.phpfreaks.com/topic/119343-sure-this-should-work-already/#findComment-614829 Share on other sites More sharing options...
DarkWater Posted August 12, 2008 Share Posted August 12, 2008 No, use his second one. This one: //This checks to see if there is a page number. If not, it will set it to page 1 if (!(isset($_GET['pagenum']))) { $pagenum = 1; } else { $pagenum = $_GET['pagenum']; } Link to comment https://forums.phpfreaks.com/topic/119343-sure-this-should-work-already/#findComment-614830 Share on other sites More sharing options...
revraz Posted August 12, 2008 Share Posted August 12, 2008 He isn't saying $pagnum, he is using your $_GET value. Link to comment https://forums.phpfreaks.com/topic/119343-sure-this-should-work-already/#findComment-614831 Share on other sites More sharing options...
s1yman Posted August 12, 2008 Author Share Posted August 12, 2008 oh, my bad. Thanks for the help Link to comment https://forums.phpfreaks.com/topic/119343-sure-this-should-work-already/#findComment-614851 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.