title: MySQLi bind_param issue in my function
body: <p>I have a function which handles MySQLi prepared queries for me. This function is designed so it's easy to type and so that I don't need to type out 3-4 lines to get a simple query to work. Here is the code:</p>
  
  <pre><code>public function preparedQuery($query, $values, $display = false)
  {    
      $mysqli = $this-&gt;connectDatabase();
  
      $repeat = str_repeat('?', count($values));
      $repeat = trim($repeat, ',');
  
      $stmt = $mysqli-&gt;prepare($query);
  
      $types = str_repeat('s', count($values));
  
      $bind = array();
  
      foreach($values as $key =&gt; $val)
      {
          $bind[$key] = &amp;$values[$key];
      }
      var_dump($query, $types, $bind);
  
      array_unshift($bind, $types);
      call_user_func_array(array($stmt, 'bind_param'), $bind);
  
      $stmt-&gt;execute();
  
      if($display)
      {
          $res = $stmt-&gt;get_result();
  
          return $res-&gt;fetch_assoc();
      }
          return true;
  }
  </code></pre>
  
  <p>As you can see this function does most things for me. I can run SELECT, UPDATE and SELECT queries and it will execute just fine. However when I attempt to run INSERT queries I get the following error:</p>
  
  <blockquote>
    <p>Warning: call_user_func_array() expects parameter 1 to be a valid
    callback, first array member is not a valid class name or object in
    C:\xampp\htdocs\system\mysqli.class.php on line 40</p>
    
    <p>Fatal error: Call to a member function execute() on a non-object in
    C:\xampp\htdocs\system\mysqli.class.php on line 42</p>
  </blockquote>
  
  <p>What I'm attempting to run is:</p>
  
  <p>For reference here are some usage examples:</p>
  
  <blockquote>
    <p>var_dump($db->preparedQuery("INSERT INTO texts (indentifier, display_text) VALUES (?, ?)", array('test1', 'test2')));</p>
  </blockquote>
  
  <p>This is the output of var_dump:</p>
  
  <blockquote>
    <p>string(59) "INSERT INTO texts (indentifier, display_text) VALUES (?, ?)" string(2) "ss" array(2) { [0]=> &amp;string(5) "test1" [1]=> &amp;string(5) "test2" } </p>
  </blockquote>
  
  <p>What am I doing wrong?</p>