I'm trying to get this php code to work, and I keep getting this
error...there may be other problems with the code, but a parse error sounds
like a syntax problem to me (I'm a beginner)...I would be so happy if
somebody could help me fix it!!
"Parse error: parse error, unexpected T_STRING in
d:\websites\stevedurkinnet\wwwroot\TMPbjeclick0n.php on line 27"
Line 27 is the first of the 25 lines that look like this: <a href="problem
lies somewhere in here"></a>.
(I'm developing a decent understanding of some of the variables and how they
interact, but I don't understand the purpose of the $alt variable or the
& thing that separates the href="XXXXXX" from the alt="XXXXXX," so if
anybody could explain that stuff too I'd be so happy.) As you may notice,
this code is for a single web page in which the one image displayed can be
changed by clicking on each of 25 links to corrresponding images.
Thanks so much for lookin',
RT
Here is the code:
<html>
<head>
<title>Paintings</title>
<link href="Style Sheets/Style01.css" rel="stylesheet" type="text/css">
</head>
<body>
<div align="center">
<?PHP
if(!isset($pn)) {
$pn = "Animals.gif";
$alt = "picture one";
}
$path = "Images\Paintings\";
$picname = $path.$pn;
$pic_size = getimagesize($picname);
print(<p>);
print(<img src=\"$picname\" $pic_size[3] alt=\"$alt\">);
print(</p>);
?>
<p>
<a href="Paintings.php?pn=Animals.gif&alt=picture%20one">Animals</a> |
<a
href="Paintings.php?pn=Antimatter.gif&alt=picture%20two">Antimatter</a>
|
<a href="Paintings.php?pn=Battle.gif&alt=picture%20three">Battle</a> |
<a href="Paintings.php?pn=Bear.gif&alt=picture%20four">Bear</a> |
<a href="Paintings.php?pn=Bird.gif&alt=picture%20five">Bird</a> |
<a href="Paintings.php?pn=Cabin.gif&alt=picture%20six">Cabin</a> |
<a href="Paintings.php?pn=Castle.gif&alt=picture%20seven">Castle</a> |
<a href="Paintings.php?pn=City.gif&alt=picture%20eight">City</a> |
<a href="Paintings.php?pn=Colorado.gif&alt=picture%20nine">Colorado</a>
|
<a
href="Paintings.php?pn=Droidling%20and%20Mother.gif&alt=picture%20ten">D
roidling and Mother</a> |
<a href="Paintings.php?pn=Dude.gif&alt=picture%20eleven">Dude</a> |
<a
href="Paintings.php?pn=Eating%20Demon.gif&alt=picture%20twelve">Eating
Demon</a> |
<a href="Paintings.php?pn=Faces.gif&alt=picture%20thirteen">Faces</a> |
<a href="Paintings.php?pn=House.gif&alt=picture%20fourteen">House</a> |
<a href="Paintings.php?pn=Path.gif&alt=picture%20fifteen">Path</a> |
<a href="Paintings.php?pn=Phantom.gif&alt=picture%20sixteen">Phantom</a>
|
<a href="Paintings.php?pn=Plan.gif&alt=picture%20seventeen">Plan</a> |
<a href="Paintings.php?pn=Skull.gif&alt=picture%20eighteen">Skull</a> |
<a
href="Paintings.php?pn=Snowman.gif&alt=picture%20nineteen">Snowman</a> |
<a href="Paintings.php?pn=Star.gif&alt=picture%20twenty">Star</a> |
<a href="Paintings.php?pn=Tree.gif&alt=picture%20twentyone">Tree</a> |
<a href="Paintings.php?pn=Vortex.gif&alt=picture%20twentytwo">Vortex</a>
|
<a href="Paintings.php?pn=Warp.gif&alt=picture%20twentythree">Warp</a> |
<a
href="Paintings.php?pn=Wizard.gif&alt=picture%20twentyfour">Wizard</a> |
<a href="Paintings.php?pn=Wolf.gif&alt=picture%20twentyfive">Wolf</a>
</p>
</div>
</body>
</html>
Change this:
> print(<p>);
> print(<img src=\"$picname\" $pic_size[3] alt=\"$alt\">);
> print(</p>);
into this:
print '<p>';
print "<img src=\"$picname\" $pic_size[3] alt=\"$alt\">";
print '</p>';
Cheers,
NC
Absolutely correct advise. However, your HTML is invalid as well. The "&
thing" you refer to is actually & (the encoded version of ampersand),
which does not belong there. Change (for example) this:
> <a href="Paintings.php?pn=Animals.gif&alt=picture%20one">Animals</a>
into this:
<a href="Paintings.php?pn=Animals.gif" alt="picture one">Animals</a>
HTH!