这个问题在这里已经有了答案:
9年前关闭。
Possible Duplicate:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in select
我正在尝试将预订日历脚本安装到服务器上,但在运行它时出现此错误。
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/illstudy/public_html/includes/functions.php on line 801
最佳答案
这意味着 mysql_query()
没有返回 MySQL 资源。它返回 bool 值 false,这通常意味着您的 SQL 中存在错误。将您的 SQL 复制并粘贴到 PhpMyAdmin 或其他数据库管理器中,看看它会吐出什么样的错误。为避免这种情况,请始终检查 mysql_query()
的返回值。在从中获取数据之前:
if( !( $result = mysql_query( "SELECT bacon FROM fridge" ) ) ) {
//Execute code here for query failure such as calling mysql_error() to discover the exact problem
}
请注意,这也可能意味着您尚未连接到 MySQL。如果你还没有这样做,试试这个:
mysql_connect( $host, $user, $pass );
关于php - 这个错误代码是什么意思 PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4778159/