James Bachini

database

  • Setting up Maxmind GEOIP2 Legacy Database with PHP or Javascript

    This is the php code I use to access geoip data from Maxmind’s geoip database: <?php $gpath = getcwd() . “/GeoIPCity.dat”; if (isset($_SERVER[‘HTTP_X_FORWARDED_FOR’])) { $myip = $_SERVER[‘HTTP_X_FORWARDED_FOR’]; } if (isset($_SERVER[‘REMOTE_ADDR’])) { $myip = $_SERVER[‘REMOTE_ADDR’]; } include(“./geoipcity.inc”); $gi = geoip_open($gpath,GEOIP_STANDARD); $record = geoip_record_by_addr($gi,$myip); $city = $record->city; $countrycode = $record->country_code; geoip_close($gi); echo ‘countrycode = “‘.$countrycode.’”; city =…

  • Automatic backup of MySQL database

    Would you like to have a backup of your critical MySQL database emailed to you automatically? The following script was moified from backup2mail and needs setting up as a cron job, instructions are in the code. Download it for free here This is what the code looks like: <?php /// Setup /// // Test it…

  • Perfect Site Structure

    It is widely accepted that Google places the most weight on the first 100 links it finds on a web page. With that in mind we can design a website that is optimised so that every single page is as close to the root domain as possible. Even with a 1,000,000+ page website you can…