0

I have stored images to SQL database with a text box and store it in database no how can I retrieve the image from database. I used the following code to display but its not working

// Grab the data from our people table
$sql = "select * from upload";
$result = mysql_query($sql) or die("Could not access DB: " . mysql_error());

while ($row = mysql_fetch_assoc($result)) {
  echo "<div class=\"picture\">";
  echo "<p>";

  // Note that we are building our src string using the filename from the database
  echo "<img src=$row['data']/>";
  echo $row['title'] . " " . $row['title'] . "<br />";
  echo "</p>";
  echo "</div>";
}
Tzar
  • 1,761
  • 2
  • 14
  • 21
sanoj lawrence
  • 951
  • 5
  • 29
  • 69
  • 6
    HOW are you storing the image? base64 encoded raw image string, or? – ʰᵈˑ Jul 16 '14 at 10:37
  • You can found your answer here: http://stackoverflow.com/questions/10850605/display-image-from-sql – Alaanor Jul 16 '14 at 10:38
  • You are trying to LITERALLY write the image to the database.. that is not how it works. You save the image on a location that the database will know how to find... –  Jul 16 '14 at 12:17
  • possible duplicate of [How to display all the images stored inside a database](http://stackoverflow.com/questions/8758548/how-to-display-all-the-images-stored-inside-a-database) – Krzysztof Safjanowski Jul 26 '14 at 02:35

1 Answers1

1

The following link may helps you.

PHP- Image upload to MySQL

set blob type for data column.

praveen0894
  • 76
  • 2
  • 9