abhay_pundir 0 Newbie Poster

hi friends, i got a problem for displaying image from the following source code

<?php
include "connection.php";
$id=$_GET['d'];// value of 'd' is getting from the another page
//$image_folder='http://192.168.0.39/OldLiveHelp/images/'; //absolute path to image folder
$msql="SELECT * from client_logo where client_id='$id'";
$mresult= mysql_query($msql) or die(mysql_error());
$row=mysql_num_rows($mresult);
if($row > 0)
{
while ($row1 = mysql_fetch_array ($mresult))
{
$im=$row1['logo'];
}
$domain="http://192.168.0.39/OldLiveHelp/images/".$im;

// get the filename extension
$ext = substr($domain, -3); // here -3 reads 3 characters from last position of the string in reverse order.

// set the MIME type
switch ($ext)
{
case 'jpg':
$mime = 'image/jpeg';
break;
case 'gif':
$mime = 'image/gif';
break;
case 'png':
$mime = 'image/png';
break;
default:
$mime = false;
}

// if a valid MIME type exists, display the image
// by sending appropriate headers and streaming the file

if ($mime)
{
header('Content-type: '.$mime);
header('Content-length: '.filesize($domain));
$file = @fopen($domain, 'rb');

if ($file)
{
fpassthru($file);

exit;
}
}
}
?>

if i give image location with image name directly instead of retrieving the name of image from database, then this code works very well. this does not.
if any of u have a better solution then suggest me.
thx in advance.