Trying to display image from mysql database
Posted: Tue Dec 10, 2002 2:10 pm
Hello,
I'm trying to insert and display BLOB images from a mySQL database. I can't seem to get any of my code to work. It just displays a cross where the image should be. I am fairly new to php so it is probably something really obvious that I'm missing.
My code to display the image is as follows - (binProductImage is a medium blob in the database):
include_once ('../includes/openconnection.php');
$get_image = "select binProductImage, filetype from tblProducts where pk_iProductID = 2";
$get_image_result = mysql_query($get_image) or die("Couldn't get image.");
$product_image = mysql_result ($get_image_result,0,"binProductImage");
$filetype = mysql_result ($get_image_result,0,"filetype");
header("Content-type: $filetype");
echo $product_image;
I'm calling this from another page by writing:
<IMG SRC="show_image.php">
I would really appreciate if anybody can help me.
Cheers,
Lisa
I'm trying to insert and display BLOB images from a mySQL database. I can't seem to get any of my code to work. It just displays a cross where the image should be. I am fairly new to php so it is probably something really obvious that I'm missing.
My code to display the image is as follows - (binProductImage is a medium blob in the database):
include_once ('../includes/openconnection.php');
$get_image = "select binProductImage, filetype from tblProducts where pk_iProductID = 2";
$get_image_result = mysql_query($get_image) or die("Couldn't get image.");
$product_image = mysql_result ($get_image_result,0,"binProductImage");
$filetype = mysql_result ($get_image_result,0,"filetype");
header("Content-type: $filetype");
echo $product_image;
I'm calling this from another page by writing:
<IMG SRC="show_image.php">
I would really appreciate if anybody can help me.
Cheers,
Lisa