0

PLz Help
i have some Images in DataBase in Blob field
but images are displayed with a Cross (X) not the actual image

MainPage.php//code

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
   die('Could not connect: ' . mysql_error());
mysql_select_db("db1", $con);
$image = mysql_query("SELECT * FROM userimagetable");
while($imageResult = mysql_fetch_array($image) ){
	?>
	<img src="ViewImage.php?id=<?=$imageResult['id']?>" alt="Picture" /></td></tr>
	<?php 
}

and the other file displaying image code is

ViewImage.php

<?php
$id = $_GET['id'];
$image = mysql_query("SELECT * FROM userimagetable WHERE Id='".$id."'");
$imageResult = mysql_fetch_array($image);
	header("Content-type: image/jpg");
echo $imageResult['UserImage'];
?>

plz help me

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by nathenastle
0

hi this is nathen,

try this in your code everything is same except $image = mysql_query("SELECT * FROM userimagetable WHERE Id=".$id); And also no need to use of header line you cna remove header("Content-type: image/jpg");so finally you code is

<?php
      $id = $_GET['id'];
      $image = mysql_query("SELECT * FROM userimagetable WHERE Id=".$id);
      $imageResult = mysql_fetch_array($image);
         echo $imageResult['UserImage'];
      ?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.