title: mysqli & bound statements, 2031: No data for parameters in statement
body: <p>Here is my code, that isn't working, don't know why:</p>
  
  <pre><code>$sql = `INSERT INTO `_translations` (id, module, item_id, name_id, output, language) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE output = ?`
  $stmt = mysqli_prepare($this-&gt;connection, $sql);
  $params = array($stmt, $types);
  foreach($array as $k=&gt;&amp;$v){
      $params[] =&amp; $v;
  }
  // this call is update call, therefore parameters are merged
  if($update &amp;&amp; $_update) $params = array_merge($params, $_update);
  call_user_func_array('mysqli_stmt_bind_param', $params); # i think the problem is in this line..
  if(mysqli_stmt_execute($stmt)){
      if($this-&gt;transaction){ $this-&gt;affected++; }
      else{ $this-&gt;affected = 1; }
  }else{ 
      $error = mysqli_stmt_error($stmt); 
      $errno = mysqli_stmt_errno($stmt);
      die("{$sql}&lt;br/&gt;&lt;pre&gt;".var_export($params, true)."&lt;/pre&gt;&lt;br/&gt;{$errno}: {$error}");
  }
  </code></pre>
  
  <p><code>die()</code> results in:</p>
  
  <pre><code>INSERT INTO `_translations` (id, module, item_id, name_id, output, language) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE output = ?
  array (
    0 =&gt; 
    mysqli_stmt::__set_state(array(
       'affected_rows' =&gt; NULL,
       'insert_id' =&gt; NULL,
       'num_rows' =&gt; NULL,
       'param_count' =&gt; NULL,
       'field_count' =&gt; NULL,
       'errno' =&gt; NULL,
       'error' =&gt; NULL,
       'sqlstate' =&gt; NULL,
       'id' =&gt; NULL,
    )),
    1 =&gt; 'isissss',
    2 =&gt; '',
    3 =&gt; 'seo',
    4 =&gt; '',
    5 =&gt; 'keywords',
    6 =&gt; 'tesoutput',
    7 =&gt; 'en',
    8 =&gt; 'tesoutput',
  )
  
  2031: No data supplied for parameters in prepared statement
  </code></pre>
  
  <p>Well, type count equals parameters and everything should be working fine, but it isn't. Since this same function runs for simple inserts, I know it works... If more data is needed from my side, feel free to ask.</p>
  
  <p>Any solutions?</p>
  
  <p>Thanks in advance!</p>
  
  <p><strong>UPDATE #1:</strong><br>
  Here are $array, $types and $update print outs.<br>
  P.S. There's a chain before each of all these 3 variables are set, but they contain exactly what's needed!</p>
  
  <pre><code>// $array
  array(6) {
    ["id"]=&gt;
    string(0) ""
    ["module"]=&gt;
    string(3) "seo"
    ["item_id"]=&gt;
    string(0) ""
    ["name_id"]=&gt;
    string(8) "keywords"
    ["output"]=&gt;
    string(9) "tesoutput"
    ["language"]=&gt;
    string(2) "en"
  }
  // $types
  string(7) "isissss"
  // $update
  array(1) {
    [0]=&gt;
    string(9) "tesoutput"
  }
  </code></pre>
  
  <p>I have already thought that the problem could be in <code>$types</code> string not maching <code>$array</code> value types, because all values are strings there. I'm not sure, though, because when inserting without update, it works, even if those are strings.</p>
  
  <p><strong>UPDATE #2:</strong><br>
  It looks like it's a version related bug, driver bug - <a href="http://bugs.php.net/bug.php?id=43568" rel="nofollow">http://bugs.php.net/bug.php?id=43568</a> ... Anyone has managed to get this to work <code>&gt; 5.2</code> with <code>mysqlnd</code>? And, yes, here on localhost I'm running <code>5.2.6</code> with default <code>mysql</code> driver, where on production server, PHP is running version <code>5.3.5</code> with <code>mysqlnd</code>.</p>