Jump to content

Problems Retrieving An Binary File(Image) From Mysql Database


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

Edited by happycoder
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...