0

I'm trying to execute my query, but get the error "Commands out of sync; you can't run this command now"

Here is my code:

public function user_info($dbusername)
        {
            if ($stmt = $this->mysqli->prepare("SELECT * FROM `accounts` WHERE `username` = ?")) {
                $stmt->bind_param("s", $dbusername);
                $stmt->execute();
                $stmt->store_result();
                //$stmt->free_result();
                if ($stmt->num_rows < 1) {
                    $stmt->close();
                    return false;
                }
                $meta = $stmt->result_metadata();
                while ($field = $meta->fetch_field()) {
                    $params[] = & $row[$field->name];
                }
                call_user_func_array(array($stmt, 'bind_result'), $params);
                $stmt->fetch();
                foreach ($row as $key => $val) {
                    $c[$key] = $val;
                }
                $stmt->free_result();
                $stmt->close();
                return $c;

            } else echo $this->mysqli->error;
            //return false;

        }
Mihail0v
  • 93
  • 1
  • 6

0 Answers0