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; ?>" />

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; ?>" />

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

Any help would be greatly appreciated.

Recommended Answers

All 12 Replies

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!

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?

I changed all the image paths in the database so they read http://www.website.com/images/imagename.jpg

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

I still can't get the image to show...anyone can help??

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:

<?php echo $row_rsInventory['small_pic']; ?>

My php code is essentially the same as yours

<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.

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

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:

<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

Member Avatar for langsor

Hi,

For debugging purposes I would do something like what Anthony is suggesting.

I would locate an image in the images directory, say G493075_101_12.jpg, and find it's database ID ... then in a simplified PHP script (in the same directory as the one you are working on), I would write the image tag statically and also immediately following I would call just that image from the database ...

$static = "website.com/images/main/G493075_101_12.jpg";
$dbase = $row_rs_listings['img_main']; // use actual specific DB call for that image ...

print "<img src=\"$static\" />";
print "<img src=\"$dbase\" />";

Here see if either show up, if the static one shows but the DB one does not then look at the source of the resultant page and see what the image-source is that is different from the static one. Possibly you are not getting results from your DB query. If neither images shows then ... then check back here and let us know what you did show up.

We're trying to find where the code is breaking, is it the database not producing results, is it the path to the image in the image directory somehow getting corrupted so it doesn't actually point to an image, is there something else going on ... we need information to figure this out.

Finally, I realized what I had wrong: in the database, I was missing one folder for the path:

website.com/images/[B]main[/B]/imagename.jpg

Thanks to everyone who helped me with this, I really appreciate it!

Finally, I realized what I had wrong: in the database, I was missing one folder for the path:

website.com/images/[B]main[/B]/imagename.jpg

Thanks to everyone who helped me with this, I really appreciate it!

It's always something simple isn't it? Glad you got sorted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.