Re: basic php problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ross a écrit :
I want to set a page number of a page

if(!isset($_REQUEST['page'])) {
$page =$_REQUEST['page'] + 1;
echo "page is ".$page; // this echos out page is 1


}


The problem is when I try and use $page further down in the body $page is 0

Question <?=$page; ?> <BR />
<? echo "page is".$page; ?>
<?=$question[($page-1)]; ?>


I also get an undefined index notice

Notice: Undefined index: page in c:\Inetpub\wwwroot\lss\module_one\evaluation.php on line 8
page is 1

but I though if I do a if(!isset($_REQUEST['page'])) this is the way to set a previously undefined index?

you have to check if page exists in $_REQUEST

if (!array_key_exists($_REQUEST,"page"))
{ $page = 1;
}

why do you wish to add something that's not set to a constant value ?

$page =$_REQUEST['page'] + 1;


NF
Ross


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux