Posts Tagged ‘mySQL’

Recording users by country

Saturday, July 19th, 2008

Detecting a user’s location requires recording and analysing their IP address. Different IP ranges are assigned to different countries. This isn’t always full proof, for example if the ISP is in another country from the user it will be recorded incorrectly. After taking note of the IP the easiest way to detect the country is to use a predefined database such as ip2nation (http://www.ip2nation.com/ ). Ip2nation is a free mySQL database of IP’s and countries. However it is isn’t documented, so takes a moment to work out how you want to use it. You can download it here: http://www.ip2nation.com/ip2nation/Download

SELECT c.country, [...]