Alternatively try this it should work i have used it a while ago in the past, The 2 parts that you need to do this are only really the HEADER line and mysql_fetch_object.
The HEADER line Content-type must be changed to match image ie image/jpg for .jpg image/gif for .gif etc etc etc.
$sql = mysql_query("select PICTURE from table where NAME= 'Aaron'");
$rows = mysql_num_rows($sql);
//check we have a result!
if($rows<1){
// no image matches this query
}
else{
// at least one record has been found
$getimage = mysql_fetch_object($sql);
// and send the correct header to the browser - THIS IS THE IMPORTANT LINE
Header("Content-type: image/jpg");
// now send the image
$image = $getimage->image;
echo $image;
flush();
}
Hope this helps!