...

View Full Version : error in else statment



runnerjp
02-15-2008, 10:30 PM
hey i dont belive i finished the code off properly because all i get for an image is
http://www.runningprofiles.com/members/images/noimage.jpg%3E%20%20%20%20 ... ect ect
Code:


<?php

$q = mysql_query($sql) or die("Error running query:".mysql_error());

if($row = mysql_fetch_array($q))
{
echo "<img src='http://www.runningprofiles.com/members/images/thumbs/". $pid . "." . $row['ext'] . "'";
}
else
{
echo "<img src='http://www.runningprofiles.com/members/images/noimage.jpg";}

?>

tomws
02-15-2008, 10:38 PM
Where is the closing forward slash and &gt; for those image tags?


<img src="some/path/pic.pic" />

Andrew Johnson
02-15-2008, 10:52 PM
You need to close your image tags, and if you're using XHTML standards throw in a slash and an alt attribute as well



<?php

$q = mysql_query($sql) or die("Error running query:".mysql_error());

if($row = mysql_fetch_array($q))
{
echo "<img src='http://www.runningprofiles.com/members/images/thumbs/". $pid . "." . $row['ext'] . "' alt='' />";
}
else
{
echo "<img src='http://www.runningprofiles.com/members/images/noimage.jpg' alt='' />";}

?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum