Page 1 of 1

storing image URLs in mysql - IMG not loading

Posted: Mon Mar 16, 2009 5:18 am
by aztech2000
I have a strange issue where images are not loading on the page. The url in source is correct and loads the image in a new window ok, just not in the page?

urls are entered via a form with php into a mysql database.

In the code the image url looks fine and loads in seperate window. I thought the problem may be with using picasa for the images but I have the same problem with localhost and other webspace.

The strange thing is the image will sometimes not load in the browser: See the attached image. The code to display with php im using is:

Code: Select all

print "
<img id='Template_".$row{'id'}."' name='Template_".$row{'id'}."' src='".$row{'thumburl'}."' width='146' height='146' border='0' alt='' />";
If anyone has any ideas why this is happening I would love to hear? I have tried url decoding when building the img src and this did not help. Is there a special way to store a URL in MYSQL DB?

Thanks Heaps

Re: storing image URLs in mysql - IMG not loading

Posted: Mon Mar 16, 2009 11:51 pm
by aztech2000
any ideas?

Could the problem be that my localhost is not configured correctly?

I only have this problem with images where the URL is loaded from the Database, not with any other site images.

Re: storing image URLs in mysql - IMG not loading

Posted: Mon Mar 16, 2009 11:57 pm
by Benjamin
Do you have error reporting turned on?

Code: Select all

 
$row{'thumburl'} // should be
$row['thumburl']
 
$row{'thumburl'} is not correct.

Re: storing image URLs in mysql - IMG not loading

Posted: Tue Mar 17, 2009 3:15 am
by aztech2000
Thanks for the reply. Yes error reporting is turned on and $row{'thumburl'} is not throwing an error.

I have changed all {} brackets to [] and the problem still exists?

I would like to explain something. When an image does not load as shown in the screenshot in my 1st post I can right click on the image placeholder and click properties. If I copy the image location URL and paste into a new window the image DOES load. Then when I go back and refresh the page the image was missing on the image re-appears.

I have tried turning off the cache but this did not help. Do you think this could be some type of caching issue?

Re: storing image URLs in mysql - IMG not loading

Posted: Tue Mar 17, 2009 3:35 am
by Benjamin
Are you sending any cache headers? Are there any cache settings configured in .htaccess? Can you please post the html, as it is sent to the browser. Also, does simply refreshing the page fix the broken image? Is this specific to one browser?

Re: storing image URLs in mysql - IMG not loading

Posted: Tue Mar 17, 2009 4:32 am
by aztech2000
I don't think im sending any cache header. No experience with doing so sorry. Also not sure how .htaccess is setup for caching.

The HTML as it appear in the browser is:

<div id='p6'> contains the painting thumbnail that is not loading in the main page.

Code: Select all

<div id='p1'>
        <a href='show-painting.php?ppage=1'><img id='Template_30' name='Template_30' src='http://www.pixelfusiondesign.com/vineofadam/images/Angelic%20DNA.jpg' width='146' height='146' border='0' alt='thumbnail' /></a></div>
            <div id='t1'>Angelic DNA</div>
    <div id='p2'>
        <a href='show-painting.php?ppage=2'><img id='Template_29' name='Template_29' src='http://lh3.ggpht.com/_r8ujfzGd8dE/SbS2hgPYw_I/AAAAAAAAANI/Lp_JAffwMts/s144/Dionysius.jpg' width='146' height='146' border='0' alt='thumbnail' /></a></div>
 
            <div id='t2'>TEST</div>
    <div id='p3'>
        <a href='show-painting.php?ppage=3'><img id='Template_26' name='Template_26' src='http://lh4.ggpht.com/_r8ujfzGd8dE/SbS2v56QpsI/AAAAAAAAAPI/aCFKyhc-Bpw/s144/Plemora%20%28detail%29.jpg' width='146' height='146' border='0' alt='thumbnail' /></a></div>
            <div id='t3'>MARY</div>
    <div id='p4'>
        <a href='show-painting.php?ppage=4'><img id='Template_25' name='Template_25' src='http://lh6.ggpht.com/_r8ujfzGd8dE/SbS2mCUJmzI/AAAAAAAAANw/f02dcOiWEcM/s144/The%20Virgin%20Mary.jpg' width='146' height='146' border='0' alt='thumbnail' /></a></div>
            <div id='t4'>THE VIRGIN MARY</div>
 
    <div id='p5'>
        <a href='show-painting.php?ppage=5'><img id='Template_24' name='Template_24' src='http://lh5.ggpht.com/_r8ujfzGd8dE/SbS2XseiyOI/AAAAAAAAALY/TvqZltrd97E/s144/The%20journey%20Back.jpg' width='146' height='146' border='0' alt='thumbnail' /></a></div>
            <div id='t5'>THE JOURNEY BACK</div>
    <div id='p6'>
        <a href='show-painting.php?ppage=6'><img id='Template_21' name='Template_21' src='http://lh6.ggpht.com/_r8ujfzGd8dE/SbS27bZ0EZI/AAAAAAAAARI/MYYiOTrscT4/vitality%20copy.jpg' width='146' height='146' border='0' alt='thumbnail' /></a></div>
            <div id='t6'>VITALITY</div> 
 
Then the strange part. As stated above, if I right click on this broken image and select properties, copy the link into a new window - the image loads. Then when I return to the page and refresh the image appears. It will then just disappear on other random refreshes?

Thanks for you're time.

Re: storing image URLs in mysql - IMG not loading

Posted: Tue Mar 17, 2009 4:35 am
by Benjamin
Are you sending html before these images have been saved to disk? Or do the images already exist on disk before you create the page?

Re: storing image URLs in mysql - IMG not loading

Posted: Tue Mar 17, 2009 5:05 am
by aztech2000
the images already exist on the disk. they are all stored on google picasa except for the top left thumb stored on another web host for testing purposes.

Re: storing image URLs in mysql - IMG not loading

Posted: Tue Mar 17, 2009 8:16 am
by Benjamin
They may be blocking hot linking. You may want to host the images yourself.

Re: storing image URLs in mysql - IMG not loading

Posted: Tue Mar 17, 2009 10:38 am
by Bill H
One of the parts of debugging is narrowing down the scope of the problem; is it a coding error, is it a server preformance problem, etc. From what you describe, it doesn't sound like there is anything you are going to be able to do with your script or your database that is going to solve it, and it is the nature of the problem that suggests that. Whether Picasa is blocking hot linking (certainly possible) or merely is not real reliable, it certainly sounds like an image hosting issue. I gave up on a couple of different image hosting services and took to hosting my own about a year ago.

I have a client who keeps calling me when their database system, which has been in place and working fine for many months, fails on one user's home computer. The error occurs only on the one person's home computer, she has tried to duplicate it and cannot, none of the other forty or so people using the system are experiencing the issue, and she wants me to do something. Or she wants me to "be sure there is not a problem." I explain to her about "scoping the problem," about viruses, bad internet connections, and bad keyboard operators, etc, and she gets it, but a few months later here she comes again.

She also wants me to design the system to prevent them from enetring senseless data and making mistakes, but that's another subject altogether.

Re: storing image URLs in mysql - IMG not loading

Posted: Tue Mar 17, 2009 10:06 pm
by aztech2000
Thanks for you're comments. I have been trying to narrow down the issue today and have the site running on a webhost. I have tested on one other PC and cannot replicate this issue. Can someone please take a look at this page and see if any images are broken?

So this may be a problem with my browser although I have no idea what this could be as the effects of the issue happen at random.

Re: storing image URLs in mysql - IMG not loading

Posted: Tue Mar 17, 2009 10:50 pm
by Benjamin
When I click that link using opera I get broken images as well. This is not a problem with your code. It is an issue with the image hosting provider. If you have a server, why aren't you hosting the images yourself?

Re: storing image URLs in mysql - IMG not loading

Posted: Tue Mar 17, 2009 11:05 pm
by aztech2000
Yes I think you are right. It must be the hosting on google picasa. I'm using online hosting so the owner of the site can upload all the photos easily in large groups and then input the URLs for these images into the PHP CMS as they enter in the painting details.

I have not coded an upload script before and read that it was not advisable to store binary image data in the database. For this reason I was hoping to use web hosting like picasa.

How can I know that this problem is definately due to an issue with the image provider?

Is there a way to cache images before writing the HTML with PHP? To ensure the image is loaded before writing to the page?

Re: storing image URLs in mysql - IMG not loading

Posted: Wed Mar 18, 2009 2:58 am
by php_east
aztech2000 wrote:I have a strange issue ..............

Code: Select all

print "
<img id='Template_".$row{'id'}."' name='Template_".$row{'id'}."' src='".$row{'thumburl'}."' width='146' height='146' border='0' alt='' />";
If anyone has any ideas why this is happening I would love to hear?
Thanks Heaps
theory (1)

my theory, without doing actual testing as that would be too much work and i hate work, is that the URL as fetched from your db is not urlencoded, as required by http. thus the space remains a space, which simply cannot come through.

when you dump the html as in <div id='p6'>, you can see a %20 in the src URL. this was done by your browser, correctly, but the src initally got a space from the db, and would not be able to find the file, and any file containing spaces.

try

Code: Select all

 
print "
<img id='Template_".$row['id']."' name='Template_".$row['id']."' src='".urlencode($row['thumburl'])."' width='146' height='146' border='0' alt='' />";

Re: storing image URLs in mysql - IMG not loading

Posted: Wed Mar 18, 2009 3:04 am
by php_east
now if theory (1) above blows, try this for sanity check...

http://lh6.ggpht.com/_r8ujfzGd8dE/SbS27 ... exists.jpg

http://lh6.ggpht.com/_r8ujfzGd8dE/SbS27 ... ing_on.jpg

http://lh6.ggpht.com/_r8ujfzGd8dE/SbS27 ... en_had.jpg

and finally this...
http://lh6.ggpht.com/_r8ujfzGd8dE/SbS27 ... YiOTrscT4/

all goes to the same picture. someone has htaccess control there.