All tutorials I have seen have pointed towards functions like geoip_record_by_name. I always get this error: Fatal error: Call to undefined function geoip
You can try hostip.info, Maxmind or ip2location to name a few. These are easy to use with PHP and can be used on shared hosting. Some of them have offline options as well.