|
Posted by tg-php on 10/21/77 11:36
I believe this may help:
http://uk2.php.net/manual/en/function.ip2long.php
It converts the IP address to the 'long' format (which is valid to put into a browser as an address btw). I think 127.0.0.1 and 127.0.0.2 will be sequential in the 'long' format. So if you convert starting address and ending address to long format and compare it with numbers stored in your database in long format, it should give you what you need.
Good luck!
-TG
= = = Original message = = =
I'm in the process of parsing through a apache access_log file and putting the information into a database. Right now I have the ip addresses going into a database as a character format xxx.xxx.xxx.xxx and then later I'm creating my queries to search for ip addresses xxx.xxx.%, which I think is really ineffecient. Therefore, I wanted to add a new field in my database which would be just an int value and have php convert the ip address to an int for database insertion. Then have an sql query that would just convert that int back into an ip address if I needed. My ultimate goal is to be able to write a query simular to this:
SELECT * FROM Apache_Stats WHERE int_ip BETWEEN INET_ATON('xxx.xxx.0.0') AND INET_ATON ('xxx.xxx.255.255')
Is there a function in PHP that will convert the xxx.xxx.xxx.xxx ip address to the same number that INET_ATON() is converting it to? I know about ip2long() but in the PHP docs it doesn't convert right unles you use the printf("%u...) function.
Thanks!
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.
Navigation:
[Reply to this message]
|