Can you slab out some of the code so we can see what you're using to compare.
You can store ip addresses as an INT field by using [man]ip2long[/man] and [man]long2ip[/man] to convert back.
There's a whole nest of vipers out there when it comes to IP tracking, but you can search on that or maybe one of the people who make more sense when trying to write more than three sentences will chip in.