[HELP] Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in

Status
Not open for further replies.

bodge

ayy lmao
Oct 31, 2011
406
54
Hello Devbest, I got an error while coding my function:

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\Users\Owner\Desktop\Billy\xampp-win32-1.8.2-2-VC9\xampp\htdocs\Pony\includes\users.inc.php on line 23

I have no idea what to do :/

PHP:
//Other functions above

function fetch_user_ids($user_names){
    foreach ($user_names as &$name){
        $name = mysql_real_escape_string($name);
    }
   
    $result = mysql_query("SELECT `id`, `username` FROM `users` WHERE `username` IN ('" . implode("', '", $user_names) . "')");
   
    $names = array();
   
    while (($row = mysql_fetch_assoc($result)) !== false){
        $names[$row['username']] = $row['id'];
    }
    return $names;
}

Thanks in advanced.
 

bodge

ayy lmao
Oct 31, 2011
406
54
Is there any data in your sql tables?
Yes

(users table)

2MLOupPg7DCoeeQC11HS62


fixed, close pls
 
Last edited by a moderator:

RastaLulz

fight teh power
Staff member
May 3, 2010
3,926
3,921
Incase someone has this issue in the future, the reason why is giving an error is because of an error in the SQL syntax. You must remove the comma from the last item that is imploded.
 
Status
Not open for further replies.

Users who are viewing this thread

Top