How get country and city using IP address in PHP -


i trying  country , city using ip address in php.my code given below. 

i got output.any body give solution these issue?i got out put these way ip address:- 127.0.0.1 city:- not define country:- not define

 <?php  /*get user ip address*/  $ip_address=$_server['remote_addr'];  /*get user ip address details geoplugin.net*/ $geopluginurl='http://www.geoplugin.net/php.gp?ip='.$ip_address; $addrdetailsarr = unserialize(file_get_contents($geopluginurl));   /*get city name return array*/ $city = $addrdetailsarr['geoplugin_city'];   /*get country name return array*/ $country = $addrdetailsarr['geoplugin_countryname'];  /*comment out these line see posible details*/ /*echo '<pre>'; print_r($addrdetailsarr); die();*/  if(!$city){ $city='not define'; }if(!$country){ $country='not define';  } echo '<strong>ip address</strong>:- '.$ip_address.'<br/>'; echo '<strong>city</strong>:- '.$city.'<br/>'; echo '<strong>country</strong>:- '.$country.'<br/>'; ?> 

you need make request come ip address on internet. sending localhost loopback network interface isn't going give server ip address has location in database.


Comments

Popular posts from this blog

c# - how to use buttonedit in devexpress gridcontrol -

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - System.FormatException' occurred in MongoDB.Bson.dll - XXX is not a valid 24 digit hex string -