Putting an image into mysql

  • DavyDuke17
  • Graduate
  • Graduate
  • DavyDuke17
  • Posts: 166

Post 3+ Months Ago

I use phpmyadmin and I want to know how I could have a field for images (photo) for each person in the database. Could I have it be a text field and then insert in <img src="place of that particular photo"> and then have it print it out? Would that work?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Yes. This should work just fine. But make the image links absolute links to the pictures. Otherwise you may run into dead link problems for the images.
  • SCRiPTOPSY
  • Newbie
  • Newbie
  • SCRiPTOPSY
  • Posts: 5

Post 3+ Months Ago

Thats a possiboilty, however you can also store the image in the database as a BLOB object, however this might take quite some more time than just saving the absolute path. On the other hand, if your user removes his image, you'll be stuck with a broken link ...
  • cipher
  • Graduate
  • Graduate
  • User avatar
  • Posts: 157

Post 3+ Months Ago

the way i do mine is i just store the filename, for example ozzu.gif then where it is required the array would call the filename into the image source tags. this way i don't think that there are any problems with the path being absolute or relative.
  • diverdan
  • Beginner
  • Beginner
  • diverdan
  • Posts: 46
  • Loc: Alabama, USA

Post 3+ Months Ago

yep, then you can have a path-to-images variable that you can change as needed
  • Rabid Dog
  • Web Master
  • Web Master
  • User avatar
  • Posts: 3245
  • Loc: South Africa

Post 3+ Months Ago

SCRiPTOPSY wrote:
Thats a possiboilty, however you can also store the image in the database as a BLOB object, however this might take quite some more time than just saving the absolute path. On the other hand, if your user removes his image, you'll be stuck with a broken link ...


The way to avoid this is probably to do a check on the image field. if it is empty then simply replace the would be filename with a fill of sorts.

I prefer storing the images in the db - like the idea of all the content in one place.

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 81 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.