开发者

mysql_num_rows returning TRUE

开发者 https://www.devze.com 2023-03-30 16:40 出处:网络
$exist query have 0 rows. $exist = mysql_query(\"SELECT post_name FROM wp_posts WHERE post_name=\'$epSlug\'\") or die(mysql_error());

$exist query have 0 rows.

$exist = mysql_query("SELECT post_name FROM wp_posts WHERE post_name='$epSlug'") or die(mysql_error());

$num_exist = mysql_num_rows($exist) 开发者_高级运维or die(mysql_error());

if(!$num_exist){
mysql_query.......
}

After my understanding, my second query should be running(inside if statement)? Can someone confirm this? Because it does not run somehow and I removed the statement and it ran. I'm really confused even though I read the manual, I've been trying a lot now, if anyone sees what I'm doing wrong please point out.

Thanks!


Try doing..

if ($num_exist > 0) { mysql_query ... }

or conversely try if (!($num_exists === 0))

As others said.. you need to test for a number not a boolean

Good luck and hth!


! = not, your only running the if clause when $num_exists returns boolean FALSE

0

精彩评论

暂无评论...
验证码 换一张
取 消