I have a PHP file with the following code to detect the user’s country:
<?php
// This code demonstrates how to lookup the country by IP Address
include("geoip/src/geoip.inc");
// Uncomment if querying against GeoIP/Lite City.
// include("geoipcity.inc");
$gi = geoip_open("geoip/src/GeoIP.dat", GEOIP_STANDARD);
$ip = $_SERVER['REMOTE_ADDR'];
if ( strpos($ip, ":") ) {
echo 'your country is ' . geoip_country_code_by_addr_v6($gi, $_SERVER['REMOTE_ADDR']);
}
else {
echo 'your country is ' . geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
}
geoip_close($gi);
?>
It works well when loaded directly as you can see here http://de.wikiarquitectura.com/skins/mirlo/geoip/find_country.php
I then have another PHP file were I’m including the first using the following code include("skins/mirlo/geoip/find_country.php");
but instead of inserting the same result you get when loading it on its own to the page it inserts only the first part (the IP part) and kills the page preventing it to keep loading. You can see it here: http://de.wikiarquitectura.com/index.php/Quelle_der_vier_Fl%C3%BCsse
By commenting out I have tested that the issue happens on line 7 of the above code $gi = geoip_open("geoip/src/GeoIP.dat", GEOIP_STANDARD);
but I don’t understand why it does work when loading it directly and doe sent when including it into another file.
Am I including it wrong? Any ideas?
Thanks!