参见英文答案 > mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc… expects parameter 1 to be resource or result 32个
关于wordpress cutom表的这个问题..
我正在创建一个插件我想检查一个名为wp_school_post表的表是否为空.
请参阅下面的代码,它会引发以下错误
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\getwp\wp-content\plugins\getwp_P\schools_post_function.php on line 7
**filled**
我的代码:
function schools_post_function()
{
// echo "Sachool POST function";
global $wpdb;
$result = $wpdb->get_results("SELECT postid from wp_school_post WHERE `postid` IS NOT NULL");
if(mysql_num_rows($result=='0'))
{
echo "not filled";
}
else
{
echo "filled";
}
}
解决方法:
尝试这个 :)
<?php
function schools_post_function()
{
global $wpdb;
$result = $wpdb->get_results("SELECT postid from wp_school_post WHERE `postid` IS NOT NULL");
if(count($result) == 0)
{
echo "not filled";
}
else
{
echo "filled";
}
}
?>
原文地址:https://codeday.me/bug/20191006/1859810.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。