PDA

View Full Version : adding images to database



lillizzierae
09-12-2007, 10:59 AM
how do i put images into the database. i have to pull images from my database onto my site and i really don't know how to upload the images to the database. any help would be appreciate it.

thank you! :D

RDM
09-12-2007, 12:25 PM
I wouldn't store the images into the database. It will take up too much room in your database file and it takes too much processing time to retrieve the image.

Store the images in your public_html folder and have the database call the url to the image.

lillizzierae
09-12-2007, 12:51 PM
the problem is my stupidity doesn't know how to do that though lol

RDM
09-12-2007, 12:57 PM
The same way you'd call the image but instead of calling the actual image from the database, you'd just call the URL to the image, such as "/images/image1.jpg", this would be a variable like $row[0]

Then you put that into your <IMG> tag:


echo '<img src="' . $row[0] . '" />';

I guess the real question is, do you know PHP and MySQL?

xtendedf
09-12-2007, 01:06 PM
The same way you'd call the image but instead of calling the actual image from the database, you'd just call the URL to the image, such as "/images/image1.jpg", this would be a variable like $row[0]

Then you put that into your <IMG> tag:


echo '<img src="' . $row[0] . '" />';

I guess the real question is, do you know PHP and MySQL?

putting the image in the database is no more inefficient that putting the thing
in the folder. you'd have to set up a lob column. it's a lot of coding though.
you a programmer?

lillizzierae
09-12-2007, 01:16 PM
i'm in school for web design. so i'm just learning php and mysql. i have a somewhat basic understanding. i'm doing my final. one of the requirements is: This site should have the ability to display images with your data pulled via the database.

honestly the teacher cannot teach so i've been having to basically teach myself.

RDM
09-12-2007, 01:34 PM
putting the image in the database is no more inefficient that putting the thing
in the folder. you'd have to set up a lob column. it's a lot of coding though.
you a programmer?

Then don't be surprised when you get CPU errors.

Calling images from a database is more inefficient than if you were to just call the image from the folder. The server then has to process that image, converting it from a BLOB column to an image that the browser can view. You have too many images and/or a lot of people trying to call that image from the database, your site (at least here at hostmonster) will slow way down and you'll hit your CPU quota and your site will be suspended until the CPU processes go down.

lillizzierae
09-12-2007, 01:37 PM
i appreciate the help. i kinda need all the help i can get when it comes to teaching myself all this. ha :)