image display from mysql Database

I am a beginner programmer looking to display images from mysql database.
I have tried many way and googled a lot but still i can not make this work.

The output i am getting is the alt attribute in my database.
my picture has these attributes in the database: piccontent picname pictype picsize
my data type is blob and the id i am working with is 47 as this is the id the picture is in on my images table on my database.
in the main html file i called a php file like this:
Your Picture Here

in get_image.php i wrote the following:

<?php require_once("connection.php"); require_once("functions.php"); $query = "SELECT picname, pictype, picsize, piccontent FROM carpetclean WHERE id = '47'"; $result = mysql_query($query) or die('Error, query failed'); $data = @MYSQL_RESULT($result,0,"piccontent"); $type = @MYSQL_RESULT($result,0,"pictype"); $size = @MYSQL_RESULT($result,0,"picsize"); header('Content-type: ' . $type); echo $data ?>

Please help.

It is good practice to store only reference to image (file name, path) in the database, not binary data itself. What is the reason to store image as binary field in the database?

I have no idea, this is what all programmers did when i looked for online help, like i said i am a beginner.

Sponsor our Newsletter | Privacy Policy | Terms of Service