Jump to content

Recommended Posts

I got this error on a code that used to work fine.

 

Warning: file_get_contents(http://api.hostip.info/country.php?ip=myip) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 500 Internal Server Error in /home/account/public_html/index.php on line 63

 

Line 63 of index.php says:

$ip = ($_SERVER["REMOTE_ADDR"]);

 

What is wrong?

Link to comment
https://forums.phpfreaks.com/topic/141386-solved-php-error/
Share on other sites

@Boom.dk

That's a fairly serious warning..  Better to fix it than avoid it.

 

You can't fix that sort of thing.  He has no control over some 3rd party site.  The 'better' thing to do would be to suppress it and check if it failed or not (as I showed in previous post)

Link to comment
https://forums.phpfreaks.com/topic/141386-solved-php-error/#findComment-740095
Share on other sites

What makes it particularly serious? It's just a HTTP error. In any case, the target script seems to be broken, so I don't think there's much to do about it.

 

well it *could* be serious if the rest of your site depends on info gathered from the file_get_contents...

Link to comment
https://forums.phpfreaks.com/topic/141386-solved-php-error/#findComment-740098
Share on other sites

I guess I misinterpreted what was meant when using "suppress".  As CV showed, you could suppress and then handle.  I assumed Boom.dk meant suppress and forget as he did not post any other solution.

 

And yes, I also imagined that a country check might be used for locale settings on the page or something.  But it was mainly the "supress and forget" assumption.

Link to comment
https://forums.phpfreaks.com/topic/141386-solved-php-error/#findComment-740101
Share on other sites

Well, yeah. :P

 

@transparencia:

From what I can gather, you are trying to determine a user's location from his/her IP. I think the best approach to solve this problem is to have a local list of IP ranges and their matching countries rather than relying on a 3rd party.

 

The IP ranges can be obtained from a site like this one:

http://www.ipaddresslocation.org/

Link to comment
https://forums.phpfreaks.com/topic/141386-solved-php-error/#findComment-740102
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.