Storing an IP as an unsigned int?

4uk4a

New Member
I read that the best way to store IP addresses in a database is to make an Unsigned Int(10) field. How do I convert the IP addresses using PHP? I've tried using\[code\]$this->ip = long2ip($_SERVER['REMOTE_ADDR']);\[/code\]But this doesn't seem to work. I found the way to convert it back to an IP address using\[code\]$this->ip = sprintf("%u", ip2long($result['ip']));\[/code\]How do I convert the IP Address initially? Should I be using PHP for this? Or would it be better to integrate into the MySQL query?
 
Back
Top