Home  >  Article  >  Backend Development  >  else不会执行是乍回事呢?解决方案

else不会执行是乍回事呢?解决方案

WBOY
WBOYOriginal
2016-06-13 12:12:521290browse

else不会执行是乍回事呢?
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

Statement:
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