I had the tech guys at Beyond Hosting install Maxmind Geo Lite 2 databases to my server.
I added this php code to the top of html document.
<?PHP
require $_SERVER['DOCUMENT_ROOT'].'/vendor/autoload.php';
$ipaddress = $_SERVER["REMOTE_ADDR"];
use \GeoIp2\Database\Reader;
$reader = new Reader($_SERVER['DOCUMENT_ROOT'].'/geolocation/GeoLite2-City.mmdb');
$record = $reader->omni($ipaddress);
?>
<?if ($record->city->name == '') $record->city->name = 'Your City';?>
And I inserted this script
<div class="clearfix grpelem" id="u164-6"><!-- content -->
<p>Are You The Right Type Of Man For A Christian Woman?</p>
<p>Men Ages 40-49 in <?=$record->city->name;?>Find Out Below...</p>
</div>
I saved the file as .php and uploaded to my server.
And nothing. The page looks the same as when it was .html.
Did I do all this right? I have very limited technical know-how.
Try being verbose and use <?php echo $record->city->name; ?>
hi zeno,
Just got this reply from bh support. It geolite 2 is installed, so I don't know what to make of this. I asked them to uninstall since apparently it doesn't work on a starter server.
Is the php code the same for geoip?

Yep, your short_tags could be off in your php.ini.
Wondering, is it a one-line hack that allows you to do this:
<?if ($record->city->name == '') $record->city->name = 'Your City';?>
instead of this (I believe you code won't work unless you change it to this):
<?if ($record->city->name == '') {$record->city->name = 'Your City';} ?>
Hi zeno and redrummr,
I tried both of your suggestions and it still doesn't work. I guess GeoLite 2 doesn't work on a starter server.
Could either of you tell me the script I need to insert to use geoip the software that Beyond Hosting says is already installed.
Got it working!
How did you do it, for future folks' reference?
Hey barnone,
I'd be interested to know how you got this working.
Are you using the Maxmind service? Or the service that comes installed with Beyond Hosting? Did you have to use SSH?