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 Quote Link to comment 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; } Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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/\ Quote Link to comment 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']; Quote Link to comment Share on other sites More sharing options...
revraz Posted August 12, 2008 Share Posted August 12, 2008 Yep, go with efficacious's suggestion. Quote Link to comment 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 Quote Link to comment 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?) Quote Link to comment 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 } Quote Link to comment 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']; } Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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.