php: get ip address location

Joined
12 Feb 2006
Posts
17,384
Location
Surrey
hoping this is nice and easy.

simple put i want to be able to get the ip address of the user (i know how to do this) but then use it to find the rough location of the address, like with sites that say you are located in london etc.

i have googled but it is only giving me how to get the address, not the location that address is in.

thanks
 
You need to look for a "ip location" database - there are a couple of free (rough and out of date ones) and several good quality paid ones.

However, it won't really work for the UK as it does in the US and Europe, who use local administrative exchanges that can be databased, as opposed to our national ones (test this out be trying to do a geoip lookup on your IP - it will tell you the location of your ISP's administrive exchange, which for me is some 300 miles away from where I am).

Another however - Maxmind offers accurate IP location services; it does not database Exchanges. Instead it partners up with people like Facebook and MSN and takes in manually entered registration data and IP addresses, thus maintaining an incredibly accurate IP database. The licenses for Maxmind cost 10 arms and 4 legs, though.
 
ahh thought this would be a simple thing with php just like to get the ip address, wasn't looking to pay for anything as it just a project to teach myself new stuff.

thanks for the reply btw

The problem is that IP addresses aren't split up geographically - there is no way to tell by analysing it where the computer happens to be. Therefore the only way to find a location is to keep a (big) database of IP addresses against locations.
 
Back
Top Bottom