Displaying database images

January 15, 2011 at 08:13:55
Specs: Windows 7
I am trying to dispay images from a mysql database using php, but so far no success.

Any help will be appreciated.

Well here is the code am using;

<?php
$link=mysql_connect("localhost","root","") or die("Unable to establish link!!".mysql_error());
mysql_select_db("bumbo_ss",$link) or die("Unable to select database");
$image = stripslashes($_REQUEST[photo]);
$rs = mysql_query("select photo from where indexNo like'%2011/02/003%'");
$row = mysql_fetch_assoc($rs);
$imagebytes = $row[$image];
header("Content-type: image/jpeg");
print $imagebytes;
?>


See More: Displaying database images

Report •


#1
January 15, 2011 at 12:06:14
Hmm, looks like it should work, what happens exactly?

Is 'photo' a BLOB column?

Also your query seems invalid 'from where' has no table name...


Report •

#2
January 16, 2011 at 23:35:58
Yeah, the photo is a blob.

However when I try to run it, all I get is a blank page.
Am not yet sure of what went wrong.

Any help!!!


Report •

#3
January 16, 2011 at 23:36:48
This is the code;

<?php
$link=mysql_connect("localhost","root","") or die("Unable to establish link!!".mysql_error());
mysql_select_db("bumbo_ss",$link) or die("Unable to select database");
$image = stripslashes($_REQUEST[photo]);
$rs = mysql_query("select photo from pics where indexNo like'%2011/02/003%'");
$row = mysql_fetch_assoc($rs);
$imagebytes = $row[$image];
header("Content-type: image/jpeg");
print $imagebytes;
?>


Report •

Related Solutions


Ask Question