title: dynamically add variables to mysql:bind_param
body: <p>I wanna add dynamically variables to mysqli:bind_param ...</p>
  
  <p>I saw a lot of tutorials and examples but the code I made isn't working for hours now.</p>
  
  <pre><code>$params = array('');
  $params[0] = $variableType; //variableType contains e.g. sssi
  
  foreach ( $data as $key =&gt; $value ) {
      array_push($params, $data[$key]); // I also tried $params[] = $value;
  }
  
  call_user_func_array(array($stmt, 'bind_param'), $this-&gt;refValues($params));
  </code></pre>
  
  <p>The refValues function looks like this ...</p>
  
  <pre><code>private function refValues(Array &amp;$arr)
  {
      $refs = array();
      foreach($arr as $key =&gt; $value)
          $refs[$key] = &amp;$arr[$key];
      return $refs;
  }
  </code></pre>
  
  <p>Error given every time I try it ...</p>
  
  <p><b>Warning</b>:  mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables in C:\Users...xxx.php on line 54</p>