1

I have queried a BLOB my mysql and using the following code I can display the image:

<?php 

header("Content-type: image/jpeg");
echo $row['image'];
?>

However, my HTML code below will not display. When i take away this php code, it displays. How can I display the image without preventing my HTML from displaying?

user3496349
  • 189
  • 2
  • 11

2 Answers2

1

Create a new file, image.php then place the above code in that file.

Then where you want to show your image/html do:

<img src="image.php" />
... rest of your html

For future reference, the same thing holds true when you are creating Javascript/CSS files via PHP.

Aziz Saleh
  • 2,687
  • 1
  • 17
  • 27
1

If you place your php code in a file called image.php, then you can try this

<img src="<?php include 'image.php'; ?>" />