i just spent nearly 3hrs trying to debug this problem so i figured i would post this just in case someone else has the same problem in the future. if you're trying to output binary data as an image in php and getting an error message like this: "the image [ ] could not be displayed because it contains errors" or a broken image red box looking thingie then check this out.
this code:
IS NOT THE SAME AS:
that blank line at the top will throw the image parsing off completely and even though by all appearances all the data is being output correctly, that extra line gap will not allow it to be read. just thought i'd post this b/c when i searched google i found a lot of people had this problem and ultimately never figured it out.
this code:
Code:
<?php
header('Content-type: image/jpeg');
include $_SERVER['DOCUMENT_ROOT'].'/includes/globals.php';
$db_con = open_db();
$image_q = 'SELECT `image` FROM `fc_pix`';
$image_r = mysql_query($image_q);
while ($image_w = mysql_fetch_array($image_r)){
echo $image_w['image'];
}
close_db($db_con)
?>
Code:
(*********pretend this is a blank line***********)
<?php
include $_SERVER['DOCUMENT_ROOT'].'/includes/globals.php
header('Content-type: image/jpeg');
$db_con = open_db();
$image_q = 'SELECT `image` FROM `fc_pix`';
$image_r = mysql_query($image_q);
while ($image_w = mysql_fetch_array($image_r)){
echo $image_w['image'];
}
close_db($db_con)
?>
Comment