title: What is going wrong here -MySQLi and Custom class
body: <p>I'm making a custom user management class that inherits from DBManager class. The problem I have so far is executing queries using mysqli prepared statements. DB connects fine but then prepare statement fails. I have mysqli object as an attribute that is shared in the class. I'm new with this mysqli (all the times I used normal mysql). Below is the constructor and insertusers method that fails.
  Thanks for your hel, and I have searched for so long now, so forgive me if there is something like this somewhere. I couldn't find it.
  Thanks again</p>
  
  <pre><code>&lt;?php
  
  protected  $dbLink;
  protected  $errorMsg = array();//Inherited by other functions
  
  public function __construct() {
  $this-&gt;dbLink = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
  if (mysqli_connect_errno()) {
      $this-&gt;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-&gt;dbLink-&gt;prepare($sql)) {
              $type = array("sssss");
              $params = array_merge($type, $arrayofValues);
              call_user_func_array(array($stmt, 'bind_param'), $this-&gt;refValues($params));
              $stmt-&gt;execute();
  
              if($stmt==-1) {
                  //query failed
                  $this-&gt;addError(mysqli_connect_error());
                  return false;
              }else {
                  return true;
              }
          }
          else{
              $this-&gt;addError("Something went wrong before InsertUsers stmt could execute well");
          }
      }
  ?&gt;
  </code></pre>