Cannot redeclare geoip_country_code_by_name

Today I had this error on my Ubuntu Linux box

Fatal error: Cannot redeclare geoip_country_code_by_name()

The reason was that I have geoip extension enabled in my PHP configuration and also I used the geoip.inc file from maxmind.com.

The solution is very simple. Actually, there are two solutions:

First is to disable the geoip extension from your configuration. In /etc/php5/apache2/conf.d/geoip.ini comment the first line:

;extension=geoip.so

The second solution: in your geoip.inc file, look for this code

  1. function geoip_country_code_by_name($gi, $name) {
  2. ...
  3. }
  4.  
  5. function geoip_country_name_by_name($gi, $name) {
  6. ...
  7. }

and replace with

  1. if (!function_exists('geoip_country_code_by_name')) {
  2. function geoip_country_code_by_name($gi, $name) {
  3. ...
  4. }
  5. }
  6.  
  7. if (!function_exists('geoip_country_name_by_name')) {
  8. function geoip_country_name_by_name($gi, $name) {
  9. ...
  10. }
  11. }

Comments

Thanks! I had the same problem and went with method 2, that fixed it :)

That's working ;) - thanks

Thanks ! you saved me !

Thanks! It Works

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.