Jump to content

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
https://forums.phpfreaks.com/topic/115624-cannot-modify-header-errror/
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??

<img src="image.php?file=2" width="64" height="64" /
>

 

OK whats the "image.php?file=2" mean?? Do i place this line of code into my php file or do i place it in a html file and then direct it to my php file??

 

I apologise for being so confused at this point!

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.

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.