0

I am getting the following error:

File Location: /var/www/app.site.com/html/admin/functions/ihooks.php Line: 600 Message: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given Error Type: Warning, Error Number: 2 Address: http://app.site.com/admin/main.php?action=report

Here is the function it refers to (starting at line 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];
            }
        }
    }
}

All help would be much appreciated!

Chris Laplante
  • 28,754
  • 17
  • 99
  • 133

1 Answers1

1

Major syntax error:

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

# is a comment char in mysql, so you've terminated your query after FROM.

If you'd had ANY kind of error handling in your code, you'd have noticed this sooner. Never EVER assume a query has succeeded. Always check for failure:

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

is the absolute LEAST you should have.

Marc B
  • 348,685
  • 41
  • 398
  • 480
  • Thanks Marc, I'm no expert by any means, just trying to help a friend out. WOuld I just remove the # or could you lead me in the direction of the correct code needed? – Bill Slover Mar 21 '13 at 20:11
  • you can escape it, e.g. `select ... FROM \#list_group`, or quote it ```select ... from `#list_group` ``` But really, you shouldn't be using "forbidden" chars in field/table names anyways. – Marc B Mar 21 '13 at 20:12
  • Ok, Thanks a bunch, much appreciated – Bill Slover Mar 21 '13 at 20:16