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
https://forums.phpfreaks.com/topic/119343-sure-this-should-work-already/
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)

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

}

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.