How do you trace the country, state, and city from one IP using PHP? Or can I get an sample code from PHP or any other language?
Geo-IP Tracking
Collapse
X
-
The only way to match IP addresses to geo-location is to refer to a database that links the two. There's nothing encoded in an IP address that implies anything about geo-location.Originally posted by Slap DotHow do you trace the country, state, and city from one IP using PHP? Or can I get an sample code from PHP or any other language?
There are companies that supply such databases. But to answer your question, you cannot use PHP alone to find this information. A variable like $_PHP_CITY would be awesome, but it just doesn't exist. -
plug in maxmind's PHP API:
http://www.maxmind.com/app/php
If you don't own your own server or your admin won't install the mod_geoip Apache module, then use the pure php module
For coding work - hit me up on andy // borkedcoder // com
(consider figuring out the email as test #1)
All models are wrong, but some are useful. George E.P. Box. p202Comment
-
You could take a look at the IP-to-Country http://www.ip-to-country.com/ database. You can download it for free. Don't know if it's free for commercial use, but at least you can test how it works.Comment
-
Yes, very fast is http://www.ip-to-country.com/ base + own script 9string
sample :
$ip_addr=getenv("REMOTE_ADDR");
$ip_int = ip2long($ip_addr);
$query_country = "select * from ip_country
where '$ip_int'>=ip_low_long
and '$ip_int'<=ip_high_long";
$result_country = mysql_query($query_country);
$num_country = mysql_num_rows($result_country);
$row = mysql_fetch_array ($result_country);
$ip = htmlspecialchars(stripslashes($row["ip"]));
MAKE MONEY $$$ => Persign 35$ -> 550 sites -> 10000 FHG !!!:::::
8 years of leadership !!! - adult datingComment
-
You can use a free service from redirectgeo.com
xxxoutsourcing.com
ICQ:119936 | Aim:xxxoutsourcing | MSN:msn@ xxxoutsourcing.com | Yahoo:xxxoutsourcing
Submitters, Designers, Programmers, Cartoonist, Creative Writers, Video & Photo Editors
Convert your Paysite into a cartoon site convert2toons.comComment


Comment