note 82219 added to function.ip2long

From: Date: Tue, 01 Apr 2008 18:02:32 +0000
Subject: note 82219 added to function.ip2long
Groups: php.notes 
Request: Send a blank email to php-notes+get-137823@lists.php.net to get a copy of this message
To nate, who advises that there is no reason to use an unsigned version of the IP in a MySQL DB: I think it would depend on your application, but personally, I find it useful to store IP's as unsigneds since MySQL has 2 native functions, INET_ATON() and INET_NTOA(), which work the same as ip2long()/long2ip() _except_ that they generate the unsigned counterpart. So if you want, you could do: -- IANA Class-B reserved/private SELECT * FROM servers WHERE ip >= INET_ATON('192.168.0.0') AND ip <= INET_ATON('192.168.255.255'); In my current application, I find it easier to use the MySQL built-ins than the PHP counter-parts. In case you're curious as to the names ATON and NTOA: ATON = address to number aka. ip2long NTOA = number to address aka. long2ip ---- Server IP: 64.71.164.2 Probable Submitter: 70.124.67.172 ---- Manual Page -- http://www.php.net/manual/en/function.ip2long.php Edit -- https://master.php.net/note/edit/82219 Del: integrated -- https://master.php.net/note/delete/82219/integrated Del: useless -- https://master.php.net/note/delete/82219/useless Del: bad code -- https://master.php.net/note/delete/82219/bad+code Del: spam -- https://master.php.net/note/delete/82219/spam Del: non-english -- https://master.php.net/note/delete/82219/non-english Del: in docs -- https://master.php.net/note/delete/82219/in+docs Del: other reasons-- https://master.php.net/note/delete/82219 Reject -- https://master.php.net/note/reject/82219 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#137823) next »