I am trying to work with geoip to display different ads to different locations. I am trying to display this code but nothing comes up:
<?php
$IP = $_SERVER["REMOTE_ADDR"];
include("geoip.inc");
$gi = geoip_open("GeoIP.dat", GEOIP_MEMORY_CACHE);
$CountryCode = geoip_country_code_by_addr($gi, $IP);
geoip_close($gi);
// ****DO NOT TOUCH ABOVE THIS LINE.******
//***Consult the Readme if you aren't sure what you're doing****
if ($CountryCode=="US"){
echo 'USA';
} else {
echo 'INTERNATIONAL OFFERS GO HERE';
}
?>
This as well, doesn't bring anything:
<?php
$country_name = apache_note("GEOIP_COUNTRY_NAME");
print "Country: " . $country_name;
?>
<?php
echo $_SERVER['GEOIP_ADDR'];
echo $_SERVER['GEOIP_CONTINENT_CODE'];
echo $_SERVER['GEOIP_COUNTRY_CODE'];
echo $_SERVER['GEOIP_COUNTRY_NAME'];
echo $_SERVER['GEOIP_REGION'];
echo $_SERVER['GEOIP_REGION_NAME'];
echo $_SERVER['GEOIP_CITY'];
echo $_SERVER['GEOIP_DMA_CODE'];
echo $_SERVER['GEOIP_AREA_CODE'];
echo $_SERVER['GEOIP_LATITUDE'];
echo $_SERVER['GEOIP_LONGITUDE'];
echo $_SERVER['GEOIP_POSTAL_CODE'];
?>
geoip says it is installed on my ubuntu. GeoIP.dat is sitting in the root folder. Can you help me and tell me what to do, so maybe I get to the bottom of this problem..? A step by step guidance can be really helpful here since I don't manage to get it working.
Many thanks!