Jump to content

database image displaying script


lAZLf

Recommended Posts

This will overload your database, not really but its just so much data your inputting.

 

Rather than inserting the entire image data stamp just put in the url where it resides in your server. As mentioned by the user above, store the images in a folder, and store the name of the image file in your database.

Link to comment
Share on other sites

So I found this script (http://www.wellho.net/mouth/937_Display-an-image-from-a-MySQL-database-in-a-web-page-via-PHP.html) to display images from a database, the only thing I don't know is what type of data (blob, binary, etc) should the image be in the database, and how to insert an image into the database.

 

Yes. This should only be used if you have a mission critical PHP project that requires major portability. Imagine 100 people view your web page, over 200+ entries would be made to your database alone just to pull out an image. Slow and choppy. Databases were meant for text, atleast classically with PHP.

Link to comment
Share on other sites

I need to store images in a database because i'm creating a forum-ish page on my website and I want to be able to get each persons avatar next to their posts. Similar to how this forum pulls out peoples avatars. Do forums do this through something else and not a database?

Link to comment
Share on other sites

No man! That would be suicide - your database would be huge and toooo slow.  :o Think once again - instead of storing image in database you will store simple images/forum/avatar/user_x_avatar_0001092whatever_unique_name.jpg. Actually here is what you should have:

1. in config file somewhere you should have stored path to user avatars: $avatar_path = example images/forum/avatar

2. in user table add additional field: img_avatar and store name of image assigned for user

 

There you go! Next time when you need to show image for specific user just echo image HTML elements. Example:

<img id="avatar" class="img_avatar" src="<?php echo $avatar_path .'/' .$row['img_avatar']" width="80px" height="80px"> 

 

Buddy, do whatever you want but don't store image in database :-\

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.