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

function geoip_country_code_by_name($gi, $name) {
...
}
 
function geoip_country_name_by_name($gi, $name) {
...
}

and replace with

if (!function_exists('geoip_country_code_by_name')) {
  function geoip_country_code_by_name($gi, $name) {
  ...
  }
}
 
if (!function_exists('geoip_country_name_by_name')) {
  function geoip_country_name_by_name($gi, $name) {
  ...
  }
}

 

 

5 thoughts on “Cannot redeclare geoip_country_code_by_name”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.