Image Retrieving Problem
Posted: Mon Mar 07, 2011 1:08 am
Hi,
am new PHP Programmer, here i want display the image from database, i can store the image into database,
but i cant retrieve the image, while am googling for that i got piece of code, but i unable to process it ..it show me just 1 URL
cant display the image.
Here i the code
when i code this code into the php
header("Content-type: image/jpeg");
it shows me just one link
http://localhost/mar4task/shoppingcart1/imagedb.php..
please sort out my issue ?
am new PHP Programmer, here i want display the image from database, i can store the image into database,
but i cant retrieve the image, while am googling for that i got piece of code, but i unable to process it ..it show me just 1 URL
cant display the image.
Here i the code
Code: Select all
<?php
// just so we know it is broken
error_reporting(E_ALL);
// some basic sanity checks
if(isset($_POST['image_id']) && is_numeric($_POST['image_id'])) {
//connect to the db
$link = mysql_connect("localhost", "root", "") or die("Could not connect: " . mysql_error());
// select our database
mysql_select_db("database1") or die(mysql_error());
// get the image from the db
$sql = "SELECT image FROM testblob WHERE imageid=1";
// the result of the query
$result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
// set the header for the image
//
while ($row = mysql_fetch_array($result))
{
header("Content-type: image/jpeg");
print $row['image'];
}
// echo mysql_result($result, 0);
// close the db link
mysql_close($link);
}
else {
echo 'Please use a real id number';
}
?>header("Content-type: image/jpeg");
it shows me just one link
http://localhost/mar4task/shoppingcart1/imagedb.php..
please sort out my issue ?