i need to display an image from my php database. I know that the image is there and this should work could anyone tell me why it is not working? also i know that i am successfully connecting to the db so that is not the problem
here is page one index.php after i connected to the database
<?php
$query = mysql_query("SELECT * FROM data WHERE id= 1");
while($data=mysql_fetch_array){
?>
<p> <?php echo $data['title']; ?></p>
<img src="img.php?id=1"/>
<?php } ?>
and here is img.php
<?php
$id=$_GET['id'];
$query = mysql_query("SELECT * FROM data WHERE id= $id");
while($data= mysql_fetch_array($query)){
$image=$data['image'];
header("content-type: image/jpeg");
echo $image;
}
?>
i have been trying to find the answer to this for hours