Variable Stays the same even when url assigns new value...

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
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Variable Stays the same even when url assigns new value...

Post by Benjamin »

I am making a webpage that will alow people to view images of models by choosing a model and an image number, however whenever anyone tries to change models, it seems to be stuck on Alexa.

Here is the code...

THIS IS THE CODE FOR INDEX.PHP
<?php
if (empty($model))
{
$model = "Select A Model";
include 'header.php';
include 'firstvisit.php';
include 'footer.php';
}
else
{
if ($model = "Alexa") $path = "alexablkdrscch";
elseif ($model = "Alexia and Tyler") $path = "alextwgrsbg";
elseif ($model = "Allisin") $path = "aliovergr";
elseif ($model = "Annie and Hanna") $path = "anihangg";
elseif ($model = "Erica") $path = "erccampjungle";
elseif ($model = "Kaylee") $path = "kaybluelng";
elseif ($model = "Monica") $path = "moniroselng";
elseif ($model = "Sydney") $path = "sydfence";
include 'header.php';
include 'photos.php';
include 'footer.php';
}
?>

THIS IS THE CODE FOR PHOTOS.PHP
<div align="center">
<?php if (empty($pic)) $pic = "001"; ?>
<img src="images/<?php echo $path . $pic . ".jpg\">"?>
</div>

THE HEADER ONLY HAS 1 LINE OF CODE
<? echo $model ?>

THE FOOTER DOESN'T HAVE ANY PHP CODE

And the FIRST VISIT.php page only contains links like the following,
index.php?model=Kaylee&pic=001

Not sure why the variable refuses to change, the code seems to be in the right order.
User avatar
ILoveJackDaniels
Forum Commoner
Posts: 43
Joined: Mon May 20, 2002 8:18 am
Location: Brighton, UK

Post by ILoveJackDaniels »

Code: Select all

if ($model = "Alexa") $path = "alexablkdrscch";
You need a double equals sign in there, and for the rest of the similar lines:

Code: Select all

if ($model &#1111;b]==&#1111;/b] "Alexa") $path = "alexablkdrscch";
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Thanks Lots

Post by Benjamin »

That would be the problem, all is well now:) I have only been coding php for about a week now, I was thinking VB when I wrote that...
Post Reply