i will get right into the chase! i got the following code to display an image and some data stored in a table
<?php
if (isset($_GET['p'])){ //onclick i call that script with parameter
$d=$_GET['p']; //so p is the parametered passed to the script
$connect=mysql_connect("localhost","user","")
or die ("Check your server connection");
$db_found = mysql_select_db("mydb", $connect);
$SQL = "SELECT * FROM table
WHERE d ='$d'";
$result = mysql_query($SQL);
$row=mysql_fetch_array($result);
echo "DATA: $row[data]<br>";
header('Content-type:image/jpg');
$content = $row['image'];
echo $content;
}
?>
i get the name of the string.if i remove all the echo and leave only the echo $content; my image is shown.Furthermore if remove echo$content and leave all other echoes,my echoes is shown again!! why cant i have both image and echos together?what should i do ? thnx in advance!
Correct mime-tag for jpg images is "image/jpeg" - try that instead
As the other answer points out you need to have all your echos after the header, but if you have both echos the image probably won't display probably, you just need the one echo (echo $content) and the one header.
You have to call headers before other outputs (for example echo). Also you should use image/jpeg . Try this :
header('Content-type:image/jpeg');
echo "DATA: $row[data]<br>";
$content = $row['image'];
echo $content;