...

View Full Version : dynamic images dont load everytime



phpOnFire
03-17-2009, 06:54 AM
:confused:

This strange problem has been bugging me for days. I can't work out why the images sometimes don't load.

The code is PHP/HTML and the data is stored in MYSQL. The site is basically a gallery with thumbnails and larger images. The setup is pretty basic and all is working except for this strange problem with images not loading. The strange part is that the URL in the IMG SRC in the source code (from the database) is a correct URL and does load in a separate window. Just not in my page!

Also making this hard to troubleshoot is that it is not all images just some >> here is an example image URL: http://lh6.ggpht.com/_r8ujfzGd8dE/SbS27bZ0EZI/AAAAAAAAARI/MYYiOTrscT4/s128/vitality%20copy.jpg (This example is hosted on Picasa, I have also tried localhost and another webhost with the same issue present)

The code to generate image SRC is as follows:

print "<img id='Template_".$row{'id'}."' name='Template_".$row{'id'}."' src='".$row{'thumburl'}."' width='146' height='146' border='0' alt='' />"; Is an empty alt tag acceptable?

This is an example of one image not loading. If I go to view source and copy the URL in the IMG SRC and open the URL alone the image does load! But not in the page!
http://www.pixelfusiondesign.com/images/image-loading.jpg

Any help would be greatly appreciated.. Thanks

mlseim
03-17-2009, 01:55 PM
Empty alt tag is acceptable, and alt is required for valid XHTML, so making
it null is better than not having it.

I don't know if this will make any difference or not, but try "echo" instead of "print" ...

echo "<img id='Template_".$row{'id'}."' name='Template_".$row{'id'}."' src='".$row{'thumburl'}."' width='146' height='146' border='0' alt='' />";

There is a slight speed difference (echo is faster), but it may also be a
buffering thing between the server (sending the HTML) and the MySQL query.

This might be another solution:



$img_id=$row{'id'};
$img_thumb=$row{'thumburl'};
echo "<img id='Template_".$img_id."' name='Template_".$img_id."' src='".$img_thumb."' width='146' height='146' border='0' alt='' />";


What that does, is handles the array query separately, giving it more processing time.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum