What\'s the best practise to store IP\'s with PHP in MySQL database? There\'s a function called ip2long - but this is just for IPv4. But what about IPv6?
I know a ph
knittl was closer, instead of binary(16) use varbinary(16) as user196009 answered in a related question. It works for me. How?
Storing IP:
getResults($query); // stored as binary
?>
Retrieving IP:
getRow($query);
echo inet_ntop($stats->vis_ip); // outputs 66.102.7.104
?>
It should work with IPv6 addresses (I have an IPv4 connection). I'm not an expert so I don't know yet if varbinary length is correct, but how I said, it works for me.
In order to check if 'IPv6 Support' is enabled in your PHP version/host: