Jump to content

Cannot modify header errror


Recommended Posts

Heres my code:

 

<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<?php header("content-type:image/jpg");
require_once('conn.php');
$q = "SELECT image from images where imgid='2'";
$r = @mysqli_query ($dbc, $q);
$row = mysqli_fetch_assoc($r);
$news = imagecreatefromstring($row['image']);
$final = imagejpeg($news);
echo $final;
?>
</body>
</html>

The error i'm getting is:

 

Warning: Cannot modify header information - headers already sent by (output started at /home/content/j/e/s/jesspomfret/html/showimage2.php:6) in /home/content/j/e/s/jesspomfret/html/showimage2.php on line 6

 

 

And then the binary from my image blob shows??

I've read that this is the whitespace problem but i can't see where my problem is??

Any ideas?  Thanks guys

Link to comment
Share on other sites

After reading that i have changed my code to:

<?php
header("content-type:image/jpeg");
require_once('conn.php');
?>
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<?php
$q = "SELECT image from images where imgid='2'";
$r = @mysqli_query ($dbc, $q);
$row = mysqli_fetch_assoc($r);
$news = imagecreatefromstring($row['image']);
$final = imagejpeg($news);
echo $final;
?>
</body>
</html>

 

I still just see the binary??Why won't my image show up??

Link to comment
Share on other sites

You cannot display binary data/html at the same time. In order to display an image in html it has to be done through the img tag.

 

As you have your images stored in the database, you cannot just echo the image binary data in your page and expect the image to load.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.