查询有关问题
程序员文章站
2022-05-13 16:40:24
...
查询问题
[code=PHP][/code]
include("conn.php");
$ip=$_SERVER['REMOTE_ADDR'];
$result=mysql_query("select * form ip where iip=$ip",$conn )or die(mysql_error());
if($result){
echo "";
}else{
mysql_query("insert into ip(id,ip) values(null,'$ip')",$conn)or die(mysql_error());
}
?>
我这样写为什么不对呀?奇怪啦,我要判断客户端的ip是否存在ip表中如果不存在就插入,存在就输出失败跳转到首页,可是怎么也调试不对呀?
------解决方案--------------------
$result=mysql_query("select * form ip where iip='$ip'",$conn )or die(mysql_error());
if($result){
------解决方案--------------------
[Quote=引用:]
[code=PHP][/code]
include("conn.php");
$ip=$_SERVER['REMOTE_ADDR'];
$result=mysql_query("select * form ip where iip=$ip",$conn )or die(mysql_error());
if($result){
echo "
[code=PHP][/code]
include("conn.php");
$ip=$_SERVER['REMOTE_ADDR'];
$result=mysql_query("select * form ip where iip=$ip",$conn )or die(mysql_error());
if($result){
echo "";
}else{
mysql_query("insert into ip(id,ip) values(null,'$ip')",$conn)or die(mysql_error());
}
?>
我这样写为什么不对呀?奇怪啦,我要判断客户端的ip是否存在ip表中如果不存在就插入,存在就输出失败跳转到首页,可是怎么也调试不对呀?
------解决方案--------------------
$result=mysql_query("select * form ip where iip='$ip'",$conn )or die(mysql_error());
if($result){
------解决方案--------------------
[Quote=引用:]
[code=PHP][/code]
include("conn.php");
$ip=$_SERVER['REMOTE_ADDR'];
$result=mysql_query("select * form ip where iip=$ip",$conn )or die(mysql_error());
if($result){
echo "