$servername ='localhost';
$dbname='8684'; //数据库教程名
$dbusername ='root'; //数据库用户名
$dbpassword ='123456'; //数据库密码
$link=mysql教程_connect($servername,$dbusername,$dbpassword);
mysql_select_db($dbname) or die();
mysql_query("set names 'gbk'");
function get_real_ip(){
$ip=false;
if(!empty($_SERVER["HTTP_CLIENT_IP"])){
$ip=$_SERVER["HTTP_CLIENT_IP"];
}
if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ips教程=explode(",",$_SERVER['HTTP_X_FORWARDED_FOR']);
if ($ip){
array_unshift($ips,$ip);
$ip=FALSE;
}
for($i=0;$i
$ip=$ips[$i];
break;
}
}
}
$ip=$ip?$ip:$_SERVER['REMOTE_ADDR'];
list($ip1,$ip2,$ip3,$ip4)=explode(".",$ip);
return $ip1*pow(256,3)+$ip2*pow(256,2)+$ip3*256+$ip4;
}
$ip=get_real_ip();
$sql="select * from ip where start
$q=mysql_query($sql);
$rs=mysql_fetch_array($q);
$city=$rs["city"];
echo $city;