Not able to display the image stored in database
Posted: Mon Aug 03, 2009 10:26 pm
Hi,
I am trying to retrieve a image from MySQL database and display it on the browser using PHP. The SQL query is fine I am able to retrieve the image from the database but when I try to display it on the screen the image does not show up. Below is the two php files that I am using for displaying the image. Can someone please let me know what am I doing incorrect here...
File 1 - Containing the img tag
File 2 - Contains the code to query the database
I am trying to retrieve a image from MySQL database and display it on the browser using PHP. The SQL query is fine I am able to retrieve the image from the database but when I try to display it on the screen the image does not show up. Below is the two php files that I am using for displaying the image. Can someone please let me know what am I doing incorrect here...
File 1 - Containing the img tag
Code: Select all
<?php include("header.php"); ?>
<div id="mainContent">
<div class="pageHeader">
<h2><font color="black"> Image </font></h2>
</div>
<div>
<?php
$imageName = $_GET['imageName'];
echo '<img src="retrieve_Images.php'"/>';
?>
</div>
<?php include("footer.php"); ?>
Code: Select all
<?php
include("conf.php");
$conn = open_connection();
$imageName = 'nature';
$query = "SELECT user_image.image FROM user_image WHERE user_image.image_name='$imageName'";
$retrieve_Image_Result = mysql_query($query) or die(mysql_error()); //mysql query
if($retrieve_Image_Result){
header("Content-type: image/jpeg");
echo mysql_result($retrieve_Image_Result, 0);
}
close_connection($conn);
?>