1

I've got an problem when I want to convert an image in blob format stored in my database. When iƧ just echo $content I can actualy see the blob file printed out so there is no problem with my queries.

The problem is that my code only displays an broken image instead of the Image in the database. Does anyone know how to display the image properly?

Thanks in advance

        $content = mysql_result($result,$i,'Image');




        echo '<img src="data:image/jpeg;base64,<?php echo base64_encode($content); ?>" width="100" />';
Beunzor
  • 83
  • 1
  • 11

1 Answers1

0

The best way to do it would be to use a separate page to display the image like the following:

<?php
header("Content-Type: image/jpeg");
// Do your query
$content = mysql_result($result,$i,'Image');
echo $content;
?>

Then in another page do

<img src="pagetodisplaytheimage.php" width="100"/>

It's also answered in this question: How to display an BLOB image stored in MySql database?

Community
  • 1
  • 1
Jonnycake
  • 568
  • 4
  • 10