i'm storing ip adress in database as integer, with ip2long(), column type is unsigned int, but for some ip in database it saves as 0, i tested and some ip for ip2long function returns negative integer and when i insert it in database it saves as 0. i googled and everyone says that column must be unsigned int.
for example: ip2long("212.36.25.15"); will return -735831793 and in database it will be saved as 0
Insert the ip address using INET_ATON.
eg: INET_ATON('127.0.0.1');
get back the ip address using INET_NTOA
eg: SELECT INET_NTOA('2130706433');
You can use the MySQL function INET_ATON instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With