I put two columns in the database.
create table ips (ipstring char(20),ipint int);
ipstring is the human readable 1.2.3.4 format. ipint is the decimal conversion of the ip address.
(Technically, that's wasteful of hard drive space and it's inefficient because I could have simply converted the decimal version back to standard ip address notation but for the purpose of this test, it made troubleshooting easier).
So after I inserted all the IP addresses, I had a table like this:
mysql> select * from ips;
+-----------------+------------+
| ipstring | ipint |
+-----------------+------------+
| 1.2.3.4 | 16909060 |
| 2.3.4.5 | 33752069 |
| 10.1.1.1 | 167837953 |
| 204.1.1.1 | 2147483647 |
| 24.1.2.3.4 | 402719235 |
| 240.240.240.240 | 2147483647 |
| 5.255.255.255 | 100663295 |
+-----------------+------------+
7 rows in set (0.03 sec)
To insert the IP addresses, first I broke the ip address (1.2.3.4) into an array called $x with split so that
$x[0] = 1 (first number in the ip address)
$x[1] = 2
$x[2] = 3
$x[3] = 4 (last number in the ip address)
Then I made a variable called $temp which is the decimal conversion of the ip address:
$temp = (256256256$x[0]) + (256256$x[1]) + (256$x[2]) + ($x[3]);
So when I insert $temp as the integer instead of ip2long($ipaddress) I know that I'm putting in a value that is really the decimal conversion of the ip address.