View Single Post
  #3 (permalink)  
Old 06-03-2009, 05:20 PM
Tech Manager Tech Manager is offline
WebProWorld Pro
 
Join Date: Jan 2008
Posts: 294
Tech Manager RepRank 1
Default Re: Storing IP location in Mysql database

You can follow Wige's advice and store the IP as a string (text). I prefer storing the IP address in decimal (integer) as it makes it easier to work with later.

I wrote a tutorial called Decimal and Binary Conversion of IP Addresses. But you can use MySQL commands to easily convert the data. For instance if you retrieved the IP you can use the inet_aton('$ip') command to convert the insert the IP Address ($ip) into decimal and then add the data into the database. You can convert the Decimal Address back to octets by using inet_ntoa.
__________________
I use Country IP Blocks as added security for my networks and servers.

Last edited by Tech Manager; 06-03-2009 at 05:24 PM.
Reply With Quote