Jump to content

Problems Retrieving An Binary File(Image) From Mysql Database


happycoder

Recommended Posts

Hello everyone! The reason I came to these forums is because i have an issue with my code, could you guys look at it and tell me what i am doing wrong?I am trying to retrieve an image from my SQL database in the form of a binary blob, but it doesn't show up. This is the code of the PHP file i am using in my image src html tag:

<?phprequire_once("connect.php"); $imgd = $_get['img'];$query="SELECT * FROM ads WHERE id=$imgd";$result=mysql_query($query) or die ("Error - ");$row = mysql_fetch_assoc($result);$image = $row['fotolocatie'];  echo $image;;?>

it doesn't show the error so it isn't the query witch fails. - Kevin

Link to comment
Share on other sites

You need to set the content type using the header() function before any output:

header("content-type:image/jpeg"); // or whatever content type your image is

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...