Im trying to load and display a blob image that is stored in the database (in a LONG BLOB field). When using a gui for mysql, i can view the image, so it is stored correctly.
Now i made a php file like this blobdisplay.php:
Code: Select all
<?
$conn = mysql_connect("localhost", "user", "password")
OR DIE (mysql_error());
@mysql_select_db ("testdb", $conn) OR DIE (mysql_error());
$sql = "SELECT * FROM imagetable WHERE image_id=".$_GET["id"];
$result = mysql_query ($sql, $conn);
if (mysql_num_rows ($result)>0) {
$row = @mysql_fetch_array ($result);
$image_type = $row["image_type"];
$image = $row["image"];
header("Content-type: image/jpeg");
print $image;
}
?>Code: Select all
<? echo "<img src='blobdisplay.php?id=18'>"; ?>Thanks
Monty