January 10th, 2017, 02:49 AM
Join Date: Dec 2016
Time spent in forums: 17 h 40 m 42 sec
Reputation Power: 2
Use ip2long(ip) and to get it back use INET_NTOA(ip)
You can use an INT
$ip = ip2long($ip);
To save in mysql:
$sql = "INSERT INTO user(ip) VALUES('$ip')";
$dbQuery = mysql_query($sql,$dbLink
You can get back the ip later :
SELECT INET_NTOA(ip) FROM 'user' WHERE 1
Given a numeric IPv4 network address in network byte order, returns the dotted-quad representation of the address as a binary string. INET_NTOA() returns NULL if it does not understand its argument.
mysql> SELECT INET_NTOA(167773449); -> '10.0.5.9'