lundi 20 avril 2015

I am using Chrome and cant get image to show from mysql using php

Firstly I know I shouldn't put the image in a DB but I am still learning.

I want to show the image, where am I going wrong?

In my database I have a column Image that is a BLOB. Small sized image. And I've checked an image array is there.

After I connect the db here is the php

$result = mysql_query("SELECT Image FROM table WHERE ID = 1");
$row = mysql_fetch_array($result);
echo $row["image"];

Any help appreciated.

All I want is just the image to show. Nothing fancy as I will expand on it once I get an image up on the screen.

I think I need an extra step between fetch array to split a variable that contains just the image and to display that. This is where I get lost.

Cheers.

This is the code I use to update the DB (from a form)

  $myphoto = $_FILES['MyPhoto'];
  $query = mysql_query("UPDATE table SET Image = '$myphoto' WHERE ID = 1") or die(mysql_error());

Aucun commentaire:

Enregistrer un commentaire