I have to store an IP address into a MySQL table running on a 32 bit system.
On a 64 bit system I would simply use INT(10) UNSIGNED
since ip2long
will always be an absolute value.
How to make it work on 32 bit? I have two options.
- Remove
UNSIGNED
and store negative values, but I'm not sure if there is still a chance of values being too large or too small once this is done (because the upper limit will be decreased by half to allow for the lower limit to be negative) - Use
sprintf("%u",ip2long( $ip ))
checkout this post (will be probably slower than 1.)
Any other solutions?