note 33744 deleted from function.ip2long by sniper

From: Date: Sat, 20 Sep 2003 07:48:33 +0000
Subject: note 33744 deleted from function.ip2long by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-56797@lists.php.net to get a copy of this message
Note Submitter: nospam@mike2k.com ---- if you're using this function to complement mysql's INET_ATON and INET_NTOA it looks like you won't be able to use it. print ip2long("192.168.0.2") returns -1062731774 mysql> SELECT INET_ATON("191.168.0.2") returns 3215458306 i believe these functions should act the same and that mysql's is correct. i want to convert the dotted quad to an int(10) unsigned storable format, but PHP doesn't seem to like the 192.168.0.0/24 block. what i was trying to do was convert the IP in PHP to the long integer and dump it into the DB. PHP and MySQL calculate 10.0.0.2 the same. so it's not a non-routable block issue. they also calculate my public internet IP properly. it's this 192.168.0.* issue that i don't believe is correct. i don't see why PHP would be returning a negative number, the number should be between 0 and 4294967295 (or -1 just for the 255.255.255.255 issue..)

« previous php.notes (#56797) next »