5 Replies - 6842 Views - Last Post: 27 November 2006 - 05:45 PM

#1 matt-the-mash  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 122
  • Joined: 10-July 06

Storing images in MySql

Posted 25 November 2006 - 02:26 AM

How do i store images in a mysql database?

Does the image file get stored, or just a link to the image location on the server?
Is This A Good Question/Topic? 0
  • +

Replies To: Storing images in MySql

#2 thef0rce  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 02-November 06

Re: Storing images in MySql

Posted 25 November 2006 - 05:10 AM

storing images is possible but you have to think about performance. The best idea is to store the actual images in a folder and the paths to the images in the database.
Was This Post Helpful? 1
  • +
  • -

#3 matt-the-mash  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 122
  • Joined: 10-July 06

Re: Storing images in MySql

Posted 25 November 2006 - 08:58 AM

That makes sense.

How would i call the path from the database?

Say, i wanted to display a picture, thumb nail size in a table with some discriptive text, how do i call the path in the database? (im using php)

This post has been edited by matt-the-mash: 25 November 2006 - 09:02 AM

Was This Post Helpful? 0
  • +
  • -

#4 k0b13r  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 15
  • View blog
  • Posts: 243
  • Joined: 18-July 06

Re: Storing images in MySql

Posted 27 November 2006 - 01:49 AM

You should use
$data = mysql_fetch_row(mysql_query(SELECT <your field in table> FROM <your table> WHERE <your id or something>));


To show it use
echo $data[0];


Was This Post Helpful? 0
  • +
  • -

#5 matt-the-mash  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 122
  • Joined: 10-July 06

Re: Storing images in MySql

Posted 27 November 2006 - 04:52 AM

Thanks for the info.

I can now call the image from the database and display it correctly on the screen, but i cant seem to display it in a table.
Every time i put <table> tags around it, i just get a binary output.

Any ideas?
Was This Post Helpful? 0
  • +
  • -

#6 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: Storing images in MySql

Posted 27 November 2006 - 05:45 PM

You get binary output because that's how it's stored in the database. IIRC BLOB stands for Binary Large Object. It's basically a file stored in a database instead of in a file system. (In fact you could draw similarities between a database and a file system.)

Anywho, you need to output it without any HTMl, in other words, you'll need to treat the image store in the database just like you would a real image file.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1