Home > Backend Development > PHP Tutorial > else不会执行是乍回事呢?

else不会执行是乍回事呢?

WBOY
Release: 2016-06-23 13:42:34
Original
1068 people have browsed it

if($_POST["submit"]){
$id=$_POST["itm"];
$ip=$_SERVER["REMOTE_ADDR"];
$postdate = date('Y-m-d H:i:s', time());
$sql="select ip from ipadd where ip='$ip'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);

if (mysql_num_rows($row)  $sql="insert into ipadd (ip,id ,postdate) values ('$ip','$id','$postdate')";
$res = mysql_query($sql);

}
else{
echo "not empty";
}
}

?>


这个只会执行IF前半部分,后面的echo "not empty";这个都不会执行,帮忙看看是什么问题


回复讨论(解决方案)

if (mysql_num_rows($row) 
改为

if (mysql_num_rows($ result) 

你确定这个程序if的前半段执行的是正确的??我怎么觉得你执行的都没有连接数据库

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