ID:181293
 
I want to know - is it possible to grab someone's general location, I.E. their country, just by knowing their IP address? This would be interesting to incorporate into BYOND games.
Sometimes, sometimes not. Basically you look up the organisation the IP address is registered with, and their registered address or regional data. Which may be accurate to within the nearest country of the actual IP user, or maybe not.

For example I used to often come up being geo-located in Amsterdam, when I was in the UK.
Check out http://ipinfodb.com/ip_database.php, download one of the MySQL databases, and read up on hub://Dantom.DB.

The databases offer 3- or 4-digit precision. If ipinfodb.com doesn't have enough precision or accuracy for your needs, or if you want more global ip-to-city coverage, you can use a commercial geolocation database, like http://www.ip2location.com/default.aspx or http://www.maxmind.com/app/ip-locate.
All those little flash ads seem to tell you about the women in your area, so I'd say probably. You have to keep in mind that sometimes it'll be really innaccurate, especially if someone uses a VPN or similar service.
I've been told I'm from many different places by a lot games which try to do this. Once I was even told I was from London... You may as well just add an option to supply a location. Way easier and more accurate.
In response to Kyle_ZX
Well, usually data like geolocation is mostly used for demographic statistics. Nobody ever really expects it to be overly accurate, just general.

And of course there are instances when the data is just wrong, especially for people using services like mobile broadband where their IP is based on either the GPS location of the device or a manual "home address" entry, which allows them to set their central server to the nearest one, effectively changing their IP to one in that area. Which means they can have an IP from just about anywhere in the country at a whim.