Greetings, I need code to find out the visitors country in php.. i also need a flag for that country and a google map of his/her location... Thanks
<?php $server = ''; // MySQL hostname $username = ''; // MySQL username $password = ''; // MySQL password $dbname = ''; // MySQL db name $db = mysql_connect($server, $username, $password) or die(mysql_error()); mysql_select_db($dbname) or die(mysql_error()); $sql = 'SELECT c.country FROM ip2nationCountries c, ip2nation i WHERE i.ip < INET_ATON("'.$_SERVER['REMOTE_ADDR'].'") AND c.code = i.country ORDER BY i.ip DESC LIMIT 0,1'; list($countryName) = mysql_fetch_row(mysql_query($sql)); // Output full country name echo $countryName; ?> PHP: and download the latest ip 2 nation database from this url http://www.ip2nation.com Code (markup):
I was about to give the solution but your code is much simpler then mine ,great thank you for your help. Noddy
i picked it up from this url http://www.ip2nation.com/ip2nation/Sample_Scripts Code (markup): it also provide samples for Google Map API http://www.ip2nation.com/ip2nation/Sample_Scripts/Google_Maps_API Code (markup):
Thank you allig. Your code worked correctly. Do you have any collection of SQL database of all the cities/states in the world country wise ?