Hello all, I have spent a good few days looking over daniweb trying to get the right answer, But I am yet to find what I am looking for.

I have successfully upload my image to a folder store and named my uploaded image.

The path and file name is stored in mysql correctly.

I am having a major issue with displaying the image !!

I have connected to mysql database, pulled information from the table, but for some reason, what ever i do, I jst cant display the image.

$city = $row['city'];
		//$img1 src =\' '. $row['img1'] . '\'>
		$img1 = $row['img1'];
		//header('Content-type: image/jpg');
		//$image_name=$row['image_name'];
		//$img1 src='image/'.$row['img1'].'' .width='50' height='50'>
		//$img1 <img src='image/'.$row['img1']."' width='50' height='50'>
		//$img1 <src='image/'.$row['img1'].'' width='50' height='50'>
				
//show data		
echo "<left>";
echo "<table bordercolor='#FF9900' width=150 cellspacing=1 cellpadding=1 border=0>";
echo "<tr align='left'>";
echo "<tr align='left' width='150'>$compname</tr>";
echo "<td valign='top' <img src='<?php echo $img1; ?>' width='100' height='75' alt='compname' title='$iurl'></td>";

The above code does everything I trying to do, Even when I rollover where the image should be, I get my title tags displaying.

I would love to find the answer to what I am doing wrong or what I am missing,

Hope to get a correct reply soon,

Cheers everyone for taking your time in reading this post,

Lloyd

Recommended Answers

All 4 Replies

Well you're missing an '>' in your <td> tag to start with. Other than that, you're missing too much code to see what's going on. If that doesn't fix it.. post your mysql_query. And your table formatting looks ugly as hell as well. Missing closing tags for just about everything..

$city = $row['city'];
		//$img1 src =\' '. $row['img1'] . '\'>
		$img1 = $row['img1'];
		//header('Content-type: image/jpg');
		//$image_name=$row['image_name'];
		//$img1 src='image/'.$row['img1'].'' .width='50' height='50'>
		//$img1 <img src='image/'.$row['img1']."' width='50' height='50'>
		//$img1 <src='image/'.$row['img1'].'' width='50' height='50'>
				
//show data		
echo "<left>";
echo "<table bordercolor='#FF9900' width=150 cellspacing=1 cellpadding=1 border=0>";
echo "<tr align='left'>";
echo "<tr align='left' width='150'>$compname</tr>";
//MISSING TAG HERE
echo "<td valign='top'> <img src='<?php echo $img1; ?>' width='100' height='75' alt='compname' title='$iurl'></td>";

Hi many thanks for replying -

I have edited my table as you mentioned and included all closing tags,
I have also included mysql -

Calling the data from the database works a treat,
Im just not sure why the image(img1) does not display

while($row = mysql_fetch_array($sql_default)){ 
//get data
		$compname = $row['compname'];
		$email = $row['email'];
		$iurl = $row['iurl'];
		$dtext = $row['dtext'];
		$country = $row['country'];
		$city = $row['city'];
		$img1 = $row['img1'];
				
//show data		
echo "<table width='150' border='0' cellspacing='0' cellpadding='0'>";
echo "<tr align='left'>";
echo "<td><a href='$compname' title='click to view $compname homepage' target='_blank'>$compname</a></td>";
echo "</tr>";
echo "<tr>";
echo "<td valign='top'><img name='$img1' src='$img1' width='150' height='75' title='$compname is a $country company based in $city' alt='img1'/></td>";
echo "</tr>";
echo "<tr>";
echo "<td align='left'>$dtext<br /><a href='$iurl' title='$iurl' target='_blank'>$iurl</a><br /></td>";
echo "</tr>";
echo "</table>";
}
?>

Thanks
Lloyd

$img1 is a file location right? If you didn't already, try setting img1 to the full image location (including http:// ). It's possible it's trying to read it from the wrong directory.

view my tutorial on this here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.