BLOB image appearing as characters
Posted: Thu Apr 17, 2008 12:57 pm
I've been trying to get images to show up on my search page, but it keeps showing up as random characters, e.g. ‰usªêÂÚØæÊÙ€Û£
My images are stored as BLOBs in the database...I've already tried storing and displaying images as file pathnames, but to no avail.
I've tried most methods by Googling my problem, but it still doesn't seem to work. I've saved the image display method in one file, and then called that image in another php file and displayed it using the <img src> tag...and yet it still shows up funny characters.
I am going to post the code up for both php files.
This is code from showimage.php:
And here is the code from searchprocess.php where the image is to be displayed:
Any thoughts/ideas?
My images are stored as BLOBs in the database...I've already tried storing and displaying images as file pathnames, but to no avail.
I've tried most methods by Googling my problem, but it still doesn't seem to work. I've saved the image display method in one file, and then called that image in another php file and displayed it using the <img src> tag...and yet it still shows up funny characters.
I am going to post the code up for both php files.
This is code from showimage.php:
Code: Select all
<?php
header("Content-Type: image/jpeg");
mysql_connect(" ", " ", " ") or die(mysql_error());
mysql_select_db("property") or die(mysql_error());
// Put the value in a separate variable
$propID = ($_GET['id']);
$query = "select propertyImage1, propertyImage2, propertyImage3 from property where propertyID = $propID";
$result = mysql_query($query) or die(mysql_error());
if($row = mysql_fetch_array($result)){
$imageData1 = $row['propertyImage1'];
}
header('Content-Type: image/jpeg');
echo $imageData1;
?>
Code: Select all
<HTML>
<BODY>
<table ALIGN = "LEFT">
<font face="Arial" color="#0B3A62">
<?//display results?>
Property area: <? echo $row[0]; ?> ,
Starting bid: £<? echo $row[1]; ?> ,
<? echo $row[2]; ?> ,
<? echo $row[3]; ?> bedroomed,
<? echo $row[4];?>
<? echo $row[5];?>
<br>
<br>
<tr><tr><td><?echo "<img src =\"showimage.php?id=$row[propertyID]\">";?></td></tr></tr>
</br></br>