-2

I am using function (snippet from CSS Trics) to get country of the user based on IP. On localhost (on my computer) it is working without the problem, but once I transferred and tried website this is the error I am getting:

    Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Error contacting Geo-IP-Server' in
 /home/elsaorgr/public_html/application/core/MY_Controller.php:72 
Stack trace: #0 /home/elsaorgr/public_html/application/core/MY_Controller.php(47): MY_Controller->geo_check_ip('178.223.146.253') 
#1 /home/elsaorgr/public_html/application/core/MY_Controller.php(13): MY_Controller->_check_lang() 
#2 /home/elsaorgr/public_html/application/libraries/ends/Frontend_Controller.php(7): MY_Controller->__construct() 
#3 /home/elsaorgr/public_html/application/controllers/home.php(7): Frontend_Controller->__construct() 
#4 /home/elsaorgr/public_html/system/core/CodeIgniter.php(308): Home->__construct() 
#5 /home/elsaorgr/public_html/index.php(202): require_once('/home/elsaorgr/...') 
#6 {main} thrown in /home/elsaorgr/public_html/application/core/MY_Controller.php on line 72

Does this error have something to do with host settings? (I am using CodeIgniter 2.1)

Sasha
  • 8,521
  • 23
  • 91
  • 174
  • 2
    Possibly. Remove the `@` or look into the log for details. – mario Nov 04 '13 at 18:10
  • 2
    some shared hosting providers block file_get_contents(), however You have not shown the part of the code that fails – Ibu Nov 04 '13 at 18:11
  • @Ibu this is the part that is falling $response=@file_get_contents('http://www.netip.de/search?query='.$ip); (based on the snippet from CSS Tricks) – Sasha Nov 04 '13 at 18:15
  • Stop suppressing errors when you want to find out what is going on. – PeeHaa Nov 04 '13 at 18:36
  • @Sasha: edit improvements into your question please, not in comments. It makes it much more readable for readers who read this question in an hour's time, as they don't need to scan through a set of comments to discover your progress. – halfer Nov 04 '13 at 19:30

1 Answers1

0

I had a similar problem and hat was because of the resolver configuration. If you are using cpanel go to Networking setup > resolver configuration and set there the ips if not already set (you can use 8.8.8.8 and 8.8.4.4)

mikaint
  • 343
  • 3
  • 12