I came accross this statement for inserting an IP into a mysql table.
INSERT INTO `best` VALUES (132+256*(172+256*(109+256*(115))
I would like to know why an IP is being inserted this way, and how to actually work out what IP is being inserted
I came accross this statement for inserting an IP into a mysql table.
INSERT INTO `best` VALUES (132+256*(172+256*(109+256*(115))
I would like to know why an IP is being inserted this way, and how to actually work out what IP is being inserted
Its prefer storing the IP address in decimal (integer) as it makes it easier to work with later.
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
see this links:
http://www.countryipblocks.net/networking/ip-address-conversion-to-decimal-and-binary-equivalents/
that's way used to reduce the space used to store ip.
with this way you will store IPs in int type field, that is smaller in space than char type