I read that the best way to store IP addresses in a database is to create an Unsigned Int (10) field. How to translate IP addresses using PHP? I tried using
$this->ip = long2ip($_SERVER['REMOTE_ADDR']);
But this does not seem to work. I found a way to convert it back to an IP address using
$this->ip = sprintf("%u", ip2long($result['ip']));
How do I convert the IP address first? Should I use PHP for this? Or would it be better to integrate into a MySQL query?
source
share