查询有关问题

WBOY
Release: 2016-06-13 13:31:26
Original
773 people have browsed it

查询问题
[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 "<script> alert('失败');window.location.href='index.html'</script>";

}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 "<script> alert('失败……<br />[/Quote]<br />楼主确定是iip不是ip?<br />$result=mysql_query("select * form ip where ip='".$ip."'",$conn )or die(mysql_error()); <br /><font color='#e78608'>------解决方案--------------------<br /> $result=mysql_query("select * from ip where iip='$ip'",$conn )or die(mysql_error()); //from写错了 <div class="clear"></script>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template