FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


PHP call to GetImageSize sometimes throws warnings





bgillingham
I was wondering if anybody knows if there is a configuration or some other way to make the code not throw that error when calling GetImageSize? The warning message contains "getaddrinfo failed: Name or service not known".

I've attempted to use code that tests any URI before the call, but it seems that fopen also doesn't work.

I need to have the call in my code but, I don't ever want the end-user to see any warning message. At the time, my solution was to set the font to the same color as the background - don't ever do this! It looked nice to me, but the Google bots didn't appreciate it - and they threw away 95% of my indexed pages (from 14,000 to 650).
Daniel15
Do you know what images it's failing on? Are they images located on remote servers?

That error seems to be very popular, with 168,000 Google results for "getaddrinfo failed: Name or service not known" Razz

Quote:
I don't ever want the end-user to see any warning message

If you *really* want to do that, try putting
Code:
error_reporting(0);
at the start of your code. That will disable any error reporting at all (I believe they're still logged to the error_log file, though).

EDIT: Maybe something like this would be best:
Code:

if ($size = @getimagesize("url")) {
    // Do stuff with the $size array
} else {
    // Call failed
}


The '@' in front of getimagesize() suppresses error reporting for that function. Alternatively, just use error_reporting(0); with your current code Wink
bgillingham
daniel15 to the rescue. Thank you very much - my web site is smoother thanks to you.
Related topics
What softwares are good for biulding a webpage?
Never Mind Problem Resolved
how did you learn about html, php or other languages???
Frihost Forum does weird things
Avatars
Browser Compatibility
Changing Main Banner on Joomla
Internet Explorer
Images in MySQL
Perfectionism - is it good or bad?
Can Php call command line interfaces on the OS
Hacking
Hilarious actual quotes by religious people online and off
consistently get different script errors when logged in
Reply to topic    Frihost Forum Index -> Support and Web Hosting -> Web Hosting Support

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.