Page 1 of 1
Need Urgent Help Please
Posted: Wed Mar 14, 2012 12:21 pm
by nbasso713
My site
http://roflsearch.com has been up and running flawlessly for months. I haven't touched the code for well over a month, and out of the blue I'm getting a php error. My webhost swears nothing has changed on their end, but I expected them to say that regardless...
Error Message:
Warning: getimagesize(
http://roflsearch.com/rofl/4846.jpg) [function.getimagesize]: could not make seekable -
http://roflsearch.com/rofl/4846.jpg in /home/zomgli5/public_html/roflsearch.com/index.php on line 142
The site displays random images, and the urls that are pulled pertaining to each image is saved on a database. The problem I'm having is that the bar above the image should be the width of the image, but for whatever reason the code i'm using just stopped working out of the blue.
Code: Select all
<a id="img" href="http://roflsearch.com?img=<?php echo $next;?>">
<div id="click" style="width:<?php list($width, $height) = getimagesize($rows['url']);
echo $width;?>px;"><h5><?php list($width, $height) = getimagesize($rows['url']);
if($width < 280)
echo "Click";
else
echo "Click or Browse For Another Random Image";
?></h5></div></a>
It's pretty straight forward, this code simply checks the width of the image and sets an equal width to the bar. If the width is less than 280px a shorter amount of text is visible. Like I said, there hasn't been an issue since i first wrote this and out of the blue today i'm getting errors. All help is greatly appreciated. Many people use my site regularly so I would like to get it functioning properly for them ASAP. Thanks in advance.
Note: $rows is simply the variable I assigned to the query pulling the image url from the database
Re: Need Urgent Help Please
Posted: Wed Mar 14, 2012 4:53 pm
by requinix
You shouldn't be figuring out the image dimensions at the last minute. Do it ahead of time: when you stick the image URL into the database.
Neither should you be using HTTP to access anything on your site. Your server hosts an image? Find where it is on the filesystem and use that path instead.
Re: Need Urgent Help Please
Posted: Wed Mar 14, 2012 8:11 pm
by twinedev
More importantly than the issue of not getting the image size. That site is PAINFULLY slow! Perhaps that is they trying to access the image via http: (as mentioned above, the wrong choice), that becasue it is taking forever, php is timing out trying to obtain things?
I'm not sure how long this link is good for, but try it, and to to the TIMELINE tab, you will see it was 45 seconds to load the page!!!
http://gtmetrix.com/reports/www.roflsearch.com/tWZUJJq9
On the flip side, it could be taking 45 seconds because the function is crapping out.
Make the changes suggested by requnix and get back to us.
-Greg
Re: Need Urgent Help Please
Posted: Wed Mar 14, 2012 8:17 pm
by califdon
I'm not familiar with that error message, but in searching for the error message on Google, I found this similar sounding post:
http://stackoverflow.com/questions/3804 ... ot-working
and one of the answers that makes sense to me was:
The error is probably could not make seekable and could mean that PHP / GD cannot recognize the image file as such.
Have you tried with different images and different image formats (GIF, JPG, PNG) ?
Maybe GIF or PNG is not supported by your PHP version.
This could also explain why the problem seemed to come from nowhere, without you or your hosting service making any changes: if it's only one or a few images that can't be read by PHP's function, the error would occur only when that or those image(s) are randomly selected.
This would be one good reason to follow requinix's recommendation about determining the width when you store the image and storing the width along with it. Then you would discover any problems of this nature when you were storing the images, not when your users try to access them.
Re: Need Urgent Help Please
Posted: Wed Mar 14, 2012 8:56 pm
by nbasso713
twinedev wrote:More importantly than the issue of not getting the image size. That site is PAINFULLY slow! Perhaps that is they trying to access the image via http: (as mentioned above, the wrong choice), that becasue it is taking forever, php is timing out trying to obtain things?
I'm not sure how long this link is good for, but try it, and to to the TIMELINE tab, you will see it was 45 seconds to load the page!!!
http://gtmetrix.com/reports/www.roflsearch.com/tWZUJJq9
On the flip side, it could be taking 45 seconds because the function is crapping out.
Make the changes suggested by requnix and get back to us.
-Greg
The site had load times of 2sec or less on gtmetrix up until today. The page has the longer load times because it's failing to get the image dimensions, which has worked fine for months until today out of the blue.
So "getimagesize" is obviously causing the problem, but I don't understand why because it's worked fine for months.
Code: Select all
list($width, $height) = getimagesize($rows['url']);
Any ideas?
Re: Need Urgent Help Please
Posted: Wed Mar 14, 2012 9:01 pm
by nbasso713
califdon wrote:
This would be one good reason to follow requinix's recommendation about determining the width when you store the image and storing the width along with it. Then you would discover any problems of this nature when you were storing the images, not when your users try to access them.
Yes, I'll def need to change my upload code. But that leaves me at a loss because i already have over 9,000 images in the database so i'm not sure how i'm supposed to update all that without uploading everything all over again which would take days.
The problem is occurring with every image, and one of the first questions I asked my host was if there was some change to the server's version of php and they said nothing changed on the server.
Re: Need Urgent Help Please
Posted: Wed Mar 14, 2012 9:24 pm
by nbasso713
RESOLVED: I took the url out of the equation, and pulled the image info directly from the folder like I should have down form the start. Thanks to all that replied.
Re: Need Urgent Help Please
Posted: Wed Mar 14, 2012 9:29 pm
by califdon
Another post you might want to read:
http://www.themejoomla.com/forum/extens ... esize.html
And don't feel like you're the only one: while searching, I found this City of Halifax, Nova Scotia official website that shows these warnings right on its website, apparently nobody has alerted the webmaster!
http://www.halifaxinfo.com/themes.php?t ... ic%20Coast
Re: Need Urgent Help Please
Posted: Thu Mar 15, 2012 9:10 am
by mikosiko
nbasso713 wrote:RESOLVED: I took the url out of the equation, and pulled the image info directly from the folder like I should have down form the start. Thanks to all that replied.
meaning that you probably were opening the image directly of the original website instead of your own webserver... that point to other very well reported reason (google it)... most likely your webhosting provider
did change the value for the config variable
allow_url_fopen from 1 (default) to 0
Re: Need Urgent Help Please
Posted: Fri Mar 16, 2012 2:38 am
by twinedev
nbasso713 wrote:[in reply to storing sizes in db]
Yes, I'll def need to change my upload code. But that leaves me at a loss because i already have over 9,000 images in the database so i'm not sure how i'm supposed to update all that without uploading everything all over again which would take days.
Add a height/width field in database, set uplaoder to properly set them for new uploads.
For the 9000+ you already have, adjust your code that currently displays the images to do something such as (I'm very tired, so just giving the gist here lol)
DB: Select the data for current item, assign it to variables.
Are Height/Width Set?
--YES => Display page using them
--NO => use your code to get the size of the image, write these to the database then display the page using them.
This way, as people visit the pages, it will auto update the table for you on demand. This will keep the load down compared to running a script that does them all at once (which depending on your hosting setup, may be an issue for resource use).
-Greg