Forum Moderators: coopster

Message Too Old, No Replies

ip storage

ip, stored as Int?

         

Matthew1980

10:10 pm on Jan 7, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there people of Webmasterworld,

I would just like to ask a simple question, when storing figures in a database, using INT, you select the length value eg: 20 characters, but when it comes to storing an IP address, I would like to store the dots too, does this mean that varchar would be the best method of storing? Or is there already a function that converts ip address's into sql friendly data?

Thanks,

MRb

TheMadScientist

10:47 pm on Jan 7, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



MySQL:
INET_ATON('IP HERE') = Converts to Number
INET_NTOA('NUMERIC VAL HERE') = Converts back to IP

Matthew1980

11:06 pm on Jan 7, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Cheers TheMadScientist,

I will give that a whirl tomorrow, handy to know as they are there anyway.

MRb