Pulling images from database

Thread Solved

Join Date: Dec 2007
Posts: 52
Reputation: mgn2683 is an unknown quantity at this point 
Solved Threads: 0
mgn2683's Avatar
mgn2683 mgn2683 is offline Offline
Junior Poster in Training

Pulling images from database

 
0
  #1
Sep 4th, 2008
Hi,

I am creating a real estate site, and I need a thumbnail and full size image to display. I'd like to store the images in respective folders under the Images folder on the server, and store the file name in the database. I can't get the images to display no matter how much I play with the code.

img src="<?php echo $row_rs_listings['img_main']; ?>" />

The above is the code I've been trying to use to pull the image. I think the problem is I have no file path defined:

img src="http://website.com/images/main/<?php echo $row_rs_listings['img_main']; ?>" />

but I don't know how to complete the path so the correct image shows based on ID.

Any help would be greatly appreciated.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 110
Reputation: antwan1986 is an unknown quantity at this point 
Solved Threads: 8
antwan1986's Avatar
antwan1986 antwan1986 is offline Offline
Junior Poster

Re: Pulling images from database

 
0
  #2
Sep 4th, 2008
Hi there,

Your syntax seems fine. Can you give us an example of what that record would look like in your database?

Also, whenever you run that script and look at the source, what is the src of your image tag say? The problem could be the database connection in general, or the data IN the database. A few things but it'll be easily sorted

I'll wait for your additional details!
"Beneath this mask there is more than flesh. Beneath this mask there is an idea, Mr. Creedy, and ideas are bulletproof." - V
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 52
Reputation: mgn2683 is an unknown quantity at this point 
Solved Threads: 0
mgn2683's Avatar
mgn2683 mgn2683 is offline Offline
Junior Poster in Training

Re: Pulling images from database

 
0
  #3
Sep 5th, 2008
The record looks like this in the database:

Column: img_main

File: G493075_101_12

The same .jpg file is located on the server website.com/images/main/G493075_101_12.jpg
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 110
Reputation: antwan1986 is an unknown quantity at this point 
Solved Threads: 8
antwan1986's Avatar
antwan1986 antwan1986 is offline Offline
Junior Poster

Re: Pulling images from database

 
0
  #4
Sep 5th, 2008
Shouldn't there be a ".jpg" extension on it in the database? According to what your saying, if you echo that out it would look like:

http://website.com/images/main/G493075_101_12

Without an extension.

Anthony
"Beneath this mask there is more than flesh. Beneath this mask there is an idea, Mr. Creedy, and ideas are bulletproof." - V
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 11
Reputation: max2me99 is an unknown quantity at this point 
Solved Threads: 1
max2me99 max2me99 is offline Offline
Newbie Poster

Re: Pulling images from database

 
0
  #5
Sep 7th, 2008
I agree. I'm guessing the field in the db is a path to the image. Like images/imagename.jpg

Have you tried changing to the url for the image?
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 52
Reputation: mgn2683 is an unknown quantity at this point 
Solved Threads: 0
mgn2683's Avatar
mgn2683 mgn2683 is offline Offline
Junior Poster in Training

Re: Pulling images from database

 
0
  #6
Sep 9th, 2008
I changed all the image paths in the database so they read http://www.website.com/images/imagename.jpg

  1. <img src="<?php echo $row_rs_listings['img_main']; ?>">

I still can't get the image to show...anyone can help??
Last edited by peter_budo; Sep 10th, 2008 at 3:48 pm. Reason: Code tag correction, closing tag is [/code]
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 24
Reputation: ocbphoto is an unknown quantity at this point 
Solved Threads: 1
ocbphoto ocbphoto is offline Offline
Newbie Poster

Re: Pulling images from database

 
0
  #7
Sep 9th, 2008
I have a DB with images paths and my page is dynamic with a repeat region so it will display each Picture on the DB here is my working code
hope it helps

rsInventory is the name of my Record Set
small_pic is the name of my field in my DB

my image path on my field in the data base looks like this

images/prodpic_small/standard_cap_black.jpg

My field is a VarCHAR (45)

My php is:

  1. <?php echo $row_rsInventory['small_pic']; ?>
Last edited by ocbphoto; Sep 9th, 2008 at 2:56 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 52
Reputation: mgn2683 is an unknown quantity at this point 
Solved Threads: 0
mgn2683's Avatar
mgn2683 mgn2683 is offline Offline
Junior Poster in Training

Re: Pulling images from database

 
0
  #8
Sep 10th, 2008
My php code is essentially the same as yours

  1. <img src="<?php echo $row_rs_listings['img_main']; ?>">

So I don't know what else could be wrong. In the database I have the full url http://www.website.com/image/imagename.jpg, so in theory that should be all I need.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 24
Reputation: ocbphoto is an unknown quantity at this point 
Solved Threads: 1
ocbphoto ocbphoto is offline Offline
Newbie Poster

Re: Pulling images from database

 
0
  #9
Sep 10th, 2008
What type of engine you are using for your DB maybe is that, i have InnoDB for my images tables i am not expert on the subject but give it a try.

Try your DB in a different web server host, i am just thinking on different solutions here
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 110
Reputation: antwan1986 is an unknown quantity at this point 
Solved Threads: 8
antwan1986's Avatar
antwan1986 antwan1986 is offline Offline
Junior Poster

Re: Pulling images from database

 
0
  #10
Sep 10th, 2008
Ok sorry I totally forgot about this post but we'll get it sorted. Tell you what, lets start simple. Select a specific record from your database and do this:

  1. <p><?php echo $row_rs_listings['img_main']; ?></p>

Tell us what it gives you, we should check to see if it's even bringing anything back. Also post your whole script in code tags for us to see!

Anthony
"Beneath this mask there is more than flesh. Beneath this mask there is an idea, Mr. Creedy, and ideas are bulletproof." - V
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC