Jump to content


Photo

Syntax help


  • Please log in to reply
2 replies to this topic

#1 ev66

ev66
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 01 September 2006 - 08:02 PM

In the code below im trying to echo an image using a variable $a but cant get it to work.It works if i use the image name, but cant get it to work using the variable, any ideas please ?
Thanks

THIS DOESNT WORK
<?php $a = "ad_ink-spot.gif"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<p></p>
<p>&nbsp;</p>
<p><?php echo '<a href=' . $_SERVER['PHP_SELF'] . '><img src=images/' . $a . 'width=200 height=121 border=0 /a>'; ?>&nbsp;</p>
</body>
</html>

THIS DOES WORK
<?php $a = "ad_ink-spot.gif"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<p></p>
<p>&nbsp;</p>
<p><?php echo '<a href=' . $_SERVER['PHP_SELF'] . '><img src=images/ad_ink-spot.gif width=200 height=121 border=0 /a>'; ?>&nbsp;</p>
</body>
</html>

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 01 September 2006 - 08:41 PM

<?php echo '<a href="' . $_SERVER['PHP_SELF'] . '"><img src="images/' . $a . '" width="200" height="121" border="0"></a>'; ?>


#3 ev66

ev66
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 01 September 2006 - 09:31 PM

Thanks. It works now.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users