错误:mysql_fetch_assoc()期望参数1是资源,给定布尔值

时间:2013-03-21 20:00:31

标签: php mysql

我收到以下错误:

文件位置:/var/www/app.site.com/html/admin/functions/ihooks.php 线路:600 消息:mysql_fetch_assoc()期望参数1是资源,给定布尔值 错误类型:警告,错误号码:2 地址:http://app.site.com/admin/main.php?action=report

这是它所引用的功能(从第584行开始)

function ihook_ac_admin_get_noauth() {
$guest = array_merge(
    ac_sql_default_row('acp_globalauth', true),
    ac_sql_default_row('#user')
);
$guest['fullname'] = '';
$guest['campaigns_sent'] =
$guest['campaigns_sent_total'] =
$guest['emails_sent'] =
$guest['emails_sent_total'] = 0;
// here we should deal with groups
$guest['groups'] = array(1 => 1);
// here we should deal with allowed lists
$guest['lists'] = ac_sql_select_box_array("SELECT listid, listid FROM #list_group WHERE groupid = 1");
// here we should deal with global permissions
$sql = ac_sql_query("SELECT * FROM #group WHERE id = 1");
while ( $row = mysql_fetch_assoc($sql) ) {
    // loop through all permissions in every group
    foreach ( $row as $k => $v ) {
        // looking for perms only
        if ( substr($k, 0, 3) == 'pg_' or substr($k, 0, 2) == 'p_' ) {
            // if not set, or has NO ACCESS, overwrite
            if ( !isset($guest[$k]) or !$guest[$k] ) {
                $guest[$k] = $row[$k];
            }
        }
    }
}

非常感谢所有帮助!

1 个答案:

答案 0 :(得分:1)

主要语法错误:

[...snip...]("SELECT listid, listid FROM #list_group WHERE groupid = 1");
                                         ^---

#是mysql中的注释字符,因此您在FROM之后终止了查询。

如果你的代码中有任何类型的错误处理,你很快就会注意到这一点。从来没有假设查询成功。始终检查失败:

$result = mysql_query($sql) or die(mysql_error());

是你应该拥有的最低价。