link and passing variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
toutouffe
Forum Newbie
Posts: 3
Joined: Wed Jul 13, 2005 4:18 am

link and passing variable

Post 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
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post 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.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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 ?
toutouffe
Forum Newbie
Posts: 3
Joined: Wed Jul 13, 2005 4:18 am

Post 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
toutouffe
Forum Newbie
Posts: 3
Joined: Wed Jul 13, 2005 4:18 am

Post by toutouffe »

So it mas just brackets problem then... :)
Post Reply