Page 1 of 1

Using the database with php?

PostPosted: Mon May 28, 2007 1:35 am
by gf-jonas

I have downloaded the database data and imported it to a MySQL database. I have downloaded the code from the svn and have looked at the php brach.
It seams like the code in the svn is much older than the database as it uses a diffrent approch to getting the ip from the database.

I thought I could work around this, but I think I don't understand the database format (the conversion I need to do).
I thought I should take a.b.c.0 and make it to a long (using ip2long as suggested in ahother thread), but I get no hits on any ip's (I am using the api as well while I test and from there all the ips are known) (with no hits I mean that if (@mysql_num_rows($result) == 0) validates as true)

my php code for making the database selection looks like
$ipRange = $a . "." . $b . "." . $c . ".0";
$longIp = sprintf("%u", ip2long($ipRange));
$sql = "SELECT * FROM ip4 WHERE ip=" . $longIp;

Any suggestions on what I am doing wrong and how I should make my selection instead?

edit: I Have tested with the ip and using this becomes 3884713472 (as stated in viewtopic.php?t=194 ).