test_imagedb_create.php
<?
$dbserver = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "em";
$dbconn = @mysql_connect($dbserver,$dbuser,$dbpass) or exit("SERVER Unavailable");
@mysql_select_db($dbname,$dbconn) or exit("DB Unavailable");
$sql = "SELECT image_type,image FROM em.testblob WHERE id =". $_GET["id"];
$result = @mysql_query($sql,$dbconn) or exit("QUERY FAILED!");
$contenttype = @mysql_result($result,0,"imgtype");
$image = @mysql_result($result,0,"imgdata");
header("Content-type: $contenttype");
echo $image;
mysql_close($dbconn);
?>
MySQL table
db = em
table = testblob
CREATE TABLE testblob (
image_id tinyint(3) NOT NULL AUTO_INCREMENT,
image_type varchar(25) NOT NULL,
image longblob NOT NULL,
image_size varchar(25) NOT NULL,
image_ctgy varchar(25) NOT NULL,
image_name varchar(50) NOT NULL,
KEY image_id (image_id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Listing.php
<?php
include 'dbc.php';
$query = "SELECT * FROM em.testblob";
$data = mysql_query("SELECT * FROM em.testblob") or die(mysql_error());
$result = mysql_query($query);
while($row=mysql_fetch_array($result, MYSQL_NUM))
{
echo
"<img src=\"test_imagedb_create.php?id=".$row[0]."\" width=80 height=65>".
"<img src=\"test_imagedb_create.php?id=".$row[1]."\" width=80 height=65>".
"<img src=\"test_imagedb_create.php?id=".$row[2]."\" width=80 height=65>".
"<img src=\"test_imagedb_create.php?id=".$row[2]."\" width=80 height=65>".
"<img src=\"test_imagedb_create.php?id=".$row[3]."\" width=80 height=65>".
"<img src=\"test_imagedb_create.php?id=".$row[4]."\" width=80 height=65>".
"<img src=\"test_imagedb_create.php?id=".$row[5]."\" width=80 height=65>".
"<br>___________________________________________________________<BR /><BR />";
}
?>
my results are shown in this image link below
http://i30.tinypic.com/o0bcr6.jpg
i can't display the image stored in MySQL database....anyone please guide me. i have been working on this like forever.