| | |
Pulling images from database
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
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.
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.
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!
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
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
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
I changed all the image paths in the database so they read http://www.website.com/images/imagename.jpg
I still can't get the image to show...anyone can help??
PHP Syntax (Toggle Plain Text)
<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]
•
•
Join Date: Aug 2008
Posts: 24
Reputation:
Solved Threads: 1
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:
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:
PHP Syntax (Toggle Plain Text)
<?php echo $row_rsInventory['small_pic']; ?>
Last edited by ocbphoto; Sep 9th, 2008 at 2:56 pm.
My php code is essentially the same as yours
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.
PHP Syntax (Toggle Plain Text)
<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.
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:
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
PHP Syntax (Toggle Plain Text)
<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
![]() |
Similar Threads
Other Threads in the PHP Forum
- Previous Thread: Upload image folder
- Next Thread: Showing a list from MySQL using WHERE isnt working :(
| Thread Tools | Search this Thread |
301 apache api array autosuggest beginner binary broken cakephp checkbox class cms code compression cron curl data database date display dropdownlist dynamic echo email eregi error execution file files folder form forms function functions google href htaccess html httppost if...loop image include insert ip javascript joomla jquery key library limit link links login mail md5 menu mlm multiple mysql mysql_real_escape_string oop paypal pdf pdfdownload php phpvotingscript problem query radio random recursion remote screen script search searchbox server session sessions sms sorting source space sql syntax system table tutorial update upload url validator variable video volume votedown web website youtube zend





