Code: Select all
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test_db", $con);
$result = mysql_query("SELECT * FROM ae_gallery WHERE id='$_GET[show]' LIMIT 1");
$row = mysql_fetch_assoc( $result );
$imageData = $row['data'];
$imageExt = $row['ext'];
header('Content-Length: '.strlen($imageData));
header("Content-type: image/{$imageExt}");
echo $imageData;
mysql_close($con);
?>Code: Select all
<html>
<body>
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test_db", $con);
$result = mysql_query("SELECT * FROM ae_gallery WHERE id='$_GET[show]' LIMIT 1");
$row = mysql_fetch_assoc( $result );
$imageData = $row['data'];
$imageExt = $row['ext'];
header('Content-Length: '.strlen($imageData));
header("Content-type: image/{$imageExt}");
echo $imageData;
mysql_close($con);
?>
THIS IS TEST TEXT
</body>
</html>Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\imagetest\showimage.php:4) in C:\xampp\htdocs\imagetest\showimage.php on line 18
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\imagetest\showimage.php:4) in C:\xampp\htdocs\imagetest\showimage.php on line 19
...And then spits out really nasty looking random characters that I suppose represent the binary making up the image in the table.
How could I fix this problem?