Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    dynamic images dont load everytime



    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/Sb...ity%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:
    Code:
    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!


    Any help would be greatly appreciated.. Thanks

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,512
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    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:

    PHP Code:
    $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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •