Hi Guys
I have images that are stored in a MySQL database that im trying to pull out & display..
I cant seem to get the following code to work it just shows
Warning: Cannot modify header information - headers already sent by (output started at /home/jazzybon/public_html/photo2.php:19) in /home/jazzybon/public_html/photo2.php on line 24
I know its Header( "Content-type: $type"); but im not sure how to get the thing working & display the image
<?php
require('config2.php');
$connection = mysql_connect($dhost, $username, $password) or die(mysql_error());
mysql_select_db($database, $connection) or die(mysql_error());
//set up the query
$query = "SELECT * FROM photo WHERE id=8";
//run the query and get the number of affected rows
$result = mysql_query($query, $connection) or die('error making query');
$num=mysql_numrows($result);
$affected_rows = mysql_num_rows($result);
$i=0;
while ($i < $num) {
$id=mysql_result($result,$i,"id");
$caption=mysql_result($result,$i,"caption");
$photo=mysql_result($result,$i,"photo");
$type=mysql_result($result,$i,"type");
$i++;
if ($type=="pjpeg") {
$type = "jpeg";
}
Header( "Content-type: $type");
echo $photo;
exit;
}
echo "no image found";
?>
Thanks everyone