I want to display an image from database so i am using this script:
<?php
header("Content-type: image/jpeg");
$username = "root";
$password = "root";
$host = "localhost";
$database = "binary";
mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error());
mysql_select_db($database) or die("Can not select the database: ".mysql_error());
$id = 3;
$rows = mysql_query("SELECT image FROM imagetable WHERE id='".$id."'");
while($row=mysql_fetch_row($rows))
{
header('Content-type: image/jpg');
print "$row[0]" ;
}
?>
but when i open this file in the browser it says:
When I comment out the line
header('Content-type: image/jpg');
then the error goes and the image bytes are displayed.
Please help me. Thanks