0

I'm trying to get the latest GeoIP package to work with my local wampserver. I have all of the files - autoload, databases, etc. - setup, at least as far as I know. The code I am using is:

require_once 'GeoIP2/autoload.php';
use GeoIp2/Database/Reader;

$reader = new Reader('GeoIP2/GeoLite2-City.mmdb');
$record = $reader->city('128.101.101.101');
print($record->country->isoCode . "\n"); // 'US'

The above outputs

city('128.101.101.101'); 
print($record->country->isoCode . "\n"); 
// 'US' 

I'm using php 5.6. There aren't any errors or warnings displayed anywhere that I can find. Does anyone know what I am missing or how to troubleshoot this?

Dave
  • 5,108
  • 16
  • 30
  • 40
user3052443
  • 758
  • 1
  • 7
  • 22
  • 2
    Possible duplicate of [PHP code is not being executed, instead code shows on the page](https://stackoverflow.com/questions/5121495/php-code-is-not-being-executed-instead-code-shows-on-the-page) – aynber Apr 09 '19 at 16:46
  • Thanks for the reply but that is a different problem than this one. I know because that problem has happened to me before. :) Also, none of those things apply, like short tags, in this case. I think it might be related to the paths used by the Reader class, though they all seem valid to me. My wampserver works well for many different sites. The only failure like this is with the GeoIP code. – user3052443 Apr 09 '19 at 17:20
  • This turned out to be the file having a BOM. Removing it fixed the display problem but the GeoIP code still doesn't work. But I will start a new thread for that if I can't get it to work. – user3052443 Apr 17 '19 at 18:11

0 Answers0