I am creating a custom user management class that gets from DBManager class. The issue I've to date is performing queries using mysqli prepared claims. DB connects fine however prepare statement fails. I've mysqli object being an attribute that's shared within the class. I am new with this particular mysqli (all of the occasions I made use of normal mysql). Below may be the constructor and insertusers method that fails. Interesting hel, and that i have looked for such a long time now, so forgive me if there's something similar to this somewhere. I could not think it is. Many thanks

<?php

protected  $dbLink;
protected  $errorMsg = array();//Inherited by other functions

public function __construct() {
$this->dbLink = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if (mysqli_connect_errno()) {
    $this->addError(mysqli_connect_error());
}
}

public  function insertUsers($arrayofValues) {
        //for inserting users in the database
        $sql = "INSERT INTO users(firstname, lastname, email, username, password) VALUES(?, ?, ?, ?, ?";
        if( $stmt = $this->dbLink->prepare($sql)) {
            $type = array("sssss");
            $params = array_merge($type, $arrayofValues);
            call_user_func_array(array($stmt, 'bind_param'), $this->refValues($params));
            $stmt->execute();

            if($stmt==-1) {
                //query failed
                $this->addError(mysqli_connect_error());
                return false;
            }else {
                return true;
            }
        }
        else{
            $this->addError("Something went wrong before InsertUsers stmt could execute well");
        }
    }
?>

Close the parens in INSERT:

INSERT INTO users(firstname, lastname, email, username, password) VALUES(?, ?, ?, ?, ?)
                                                                                      ^

It always helps adding the precise error description in to the code:

        $this->addError("InsertUsers failed: " . $this->dblink->error);