mat danz
mat danz

Reputation: 27

Using the Maxmind geo IP database without GeoIP PECL extension?

I'm trying to upload my files on free webhosting, to trial. I'm getting a problem with the output of client ip locator. I'm using maxmind database. "GeoIP.dat"

<?php print geoip_database_info(GEOIP_COUNTRY_EDITION); ?>

and the output is

Fatal error: Call to undefined function geoip_database_info() in /home/u_fg176/public_html/index.php on line 15

Is it the function geoip_database_info() not found because this hosting doesn't install pecl ext for php? Or could there be another cause of this error?

Upvotes: 1

Views: 3219

Answers (2)

deceze
deceze

Reputation: 522015

It's indeed because your host didn't install the PECL extension. You can use the somewhat equivalent PEAR extension Net_GeoIP instead, which is written in PHP and can simply be included in your project:

set_include_path(get_include_path() . PATH_SEPARATOR . '/path/to/Net_GeoIP');
require_once 'Net_GeoIP/Net/GeoIP.php';

$GeoIP = Net_GeoIP::getInstance(GEOIP_COUNTRY_EDITION);
$location = $GeoIP->lookupLocation($ipAddress);

Upvotes: 2

Derk Arts
Derk Arts

Reputation: 3460

Yes that would be the reason. Ask them to enable or extension, or look for an alternative if they don't cooperate.

Upvotes: 0

Related Questions