I'm trying to convert a 0-100 score to a #1, #2, #3, ... #n benchmark rank. It order to do this, I've planned the following query:
$q= "SELECT @rownum:=0;";
$q.=" INSERT INTO ranks (`uid`, `rank`, `sample_date`) (SELECT user_id, @rownum:=@rownum+1, NOW() FROM `scores` WHERE 1 ORDER BY score DESC)";
This runs fine in the SQL console (phpmyadmin) but when trying to run through PHP's MySQLi, using their multi_query I'm running the following error:
Commands out of sync; you can't run this command now
My multi_query wrapper: (in a class that extends mysqli)
public function multiQuery($query) {
    if (@parent::multi_query($query)) {
        $i = 0; 
        do { 
            $i++; 
        } while (@parent::next_result()); 
    }
    if (!$result) {
        printf("MySQLi error:<br><b>%s</b><br>%s <br>", $this->error, $query);
    }
    return $result;
}
Why am I getting that error?
 
    