Page 1 of 1

link and passing variable

Posted: Wed Jul 13, 2005 4:49 am
by toutouffe
Hi,

I have a php page and I reload the page when a button is clicked. I also send a few variables.
this is my code :

<a href="slideShow.php?dossier=<?PHP echo $dossier.'&categorie='.$categorie.'&photo='.$photo-1;?>"

and I get the variables with :
<?PHP
$dossier = $HTTP_GET_VARS["dossier"];
$categorie = $HTTP_GET_VARS["categorie"];
$photo = $HTTP_GET_VARS["photo"];
?>

And that doesn't work. The $dossier variable seems to be sent, but the two others don't, I have the errors :
Notice: Undefined index: categorie in c:\program files\easyphp1-8\www\slideshow\slideshow.php
Notice: Undefined index: photo in c:\program files\easyphp1-8\www\slideshow\slideshow.php

Thanks a lot

Toutouffe

Posted: Wed Jul 13, 2005 4:54 am
by phpScott
please use the approprate tags around your code, cheers.
What does the link look like when you view source it?

to fix your warnings try

Code: Select all

if(isset($_GET["dossier"]) && $_GET["dossier"] != "")
 // do something with the variable.

Posted: Wed Jul 13, 2005 4:55 am
by anjanesh

Code: Select all

&lt;a href=&quote;slideShow.php?dossier=&lt;?php echo $dossier.'&amp;categorie='.$categorie.'&amp;photo='.($photo-1);?&gt;&quote;

Code: Select all

$dossier   = $_GET["dossier"];
$categorie = $_GET["categorie"];
$photo     = $_GET["photo"];
print_r($_GET);
Whats the output ?

Posted: Wed Jul 13, 2005 5:05 am
by toutouffe
When I view the source code I have :

Code: Select all

<a href=&quote;slideShow.php?dossier=0&quote;>
OK, great Anjanesh, with your code it works....

thanks a lot

Toutouffe

Posted: Wed Jul 13, 2005 5:07 am
by toutouffe
So it mas just brackets problem then... :)