To get the user’s IP I’m using:
$ip = $_SERVER['REMOTE_ADDR'];
I have a geo database with the following tables:
blocks
locations
zipcodes
nations
dma_codes
states
This is the table I’m interested in
blocks
start_ip | end_ip | location_id
-------------------------------
33996344 | 33996351 | 16373
50331648 | 67166463 | 223
etc...
Above are just the first 2 records of the 1,866,401 rows in total in that table. I have no idea which geo database this is. Maybye MaxMind but not sure. I inherited this project from the client’s previous developer who uploaded this database but didn’t do anything with it yet. So I have no code samples to go on.
Can anyone please explain how I would get the location_id if my ip address happens to be:
72.63.83.41
Also does anyone recognize these table names so maybye I can find out which geo db this is.
IPv4 addresses are just 32bit integers, and you can use MySQL to convert a ‘string’ IP address to/from those ints via
inet_ntoa()(number to ascii) andinet_aton()(ascii to number).would give you any matching location_id for that particular IP.