Home > Backend Development > PHP Tutorial > 调试有关问题呀

调试有关问题呀

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

调试问题呀
[code=PHP][/code]
include("conn.php");
$ip=$_SERVER['REMOTE_ADDR'];
$result=mysql_query("select * from ip where id=$_GET[id] ",$conn )or die(mysql_error());
if($ip=iip){

echo "shibei>";

}else{
mysql_query("insert into ip(id,iip) values(null,'$ip')",$conn)or die(mysql_error());
}
 ?>
这个对吗?我想判断的是当ip表中的id等于一个数例如等译id=4时对应着的iip这个值是否等于$ip这个值,我这样写好像是判断不了呀,我应该怎么写呀,调试了好大一会儿了 没有办法了

------解决方案--------------------
include("conn.php");
$ip=$_SERVER['REMOTE_ADDR'];
$result=mysql_query("select * from ip where id=$_GET[id] ",$conn )or die(mysql_error());
$row=mysql_fetch_assoc($result);
if($ip==$row['iip']){

echo "shibei>";

}else{
mysql_query("insert into ip(id,iip) values(null,'$ip')",$conn)or die(mysql_error());
}
 ?>
------解决方案--------------------
if($ip=iip){ 这是毛啊

if ($result === false || mysql_num_rows() == 0) {
echo "shibai
";
} else {
$result = insert.....
if ($result === false) {
//说明在select与insert之前有其他进程插入了此IP,也应该返回失败。
//要求数据库中IP字段建唯一索引
}
}
------解决方案--------------------
[Quote=引用:]
[code=PHP][/code]
include("conn.php");
$ip=$_SERVER['REMOTE_ADDR'];
$result=mysql_query("select * from ip where id=$_GET[id] ",$conn )or die(mysql_error());
if($ip=iip){ //这个是???

echo "shibei>";
……
[/Quote]
$ip=iip ,这个ipp应该是变量吧!根源应该就在这里了!

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