Robert Everland III wrote:
> How would I go about querying an ip address in a table.
>
> I need to pass in an ip address and  be able to tell if that ip address is 
> between a starting and ending address to get a user's location.
>   

I would convert the IPs to bigints (using an ip2num function) and then 
just do a sql BETWEEN.

<cfscript>
function ip2number( sIp )
        {
          IPArray = listToArray( sIp, "." );
          return  ( IPArray[1] * ( 256 )^3 ) +
                  ( IPArray[2] * ( 256 )^2 ) +
                  ( IPArray[3] * 256 ) +
                    IPArray[4];
        }
</cfscript>



Mingo.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:244969
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to