Jump to content

Sure this should work already


s1yman

Recommended Posts

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
Share on other sites

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.8)

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.