title: Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement error
body: <p>I had a mysql query and I was converting it to mysqli(prepared statement) but I ran in to a problem which throws the below error,</p>
  <blockquote>
  <p>Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement</p>
  </blockquote>
  <p>Mysql code</p>
  <pre><code>$random_name_generated = vpb_generate_random_name().'.jpg'; //Generated name for uploaded files or images
  
  if (move_uploaded_file($_FILES['file_to_upload']['tmp_name'], $final_uploads_location)) {
      $check_empty_field = mysql_query(&quot;select * from `vpb_uploads` where `username` = '&quot;.mysql_real_escape_string(strip_tags($username)).&quot;'  and `firstname` = '&quot;.mysql_real_escape_string(&quot;&quot;).&quot;' and `lastname` = '&quot;.mysql_real_escape_string(&quot;&quot;).&quot;'&quot;);
      if (mysql_num_rows($check_empty_field) &lt; 1) {
          mysql_query(&quot;insert into `vpb_uploads` values('', '&quot;.mysql_real_escape_string($username).&quot;', '', '', '&quot;.mysql_real_escape_string($random_name_generated).&quot;', '', '', '', '', '&quot;.mysql_real_escape_string(date(&quot;d-m-Y&quot;)).&quot;')&quot;);
  
          $identity = &quot;image_one&quot;;
      } else {
          $get_empty_field = mysql_fetch_array($check_empty_field);
          $image_one = strip_tags($get_empty_field[&quot;image_one&quot;]);
          $image_two = strip_tags($get_empty_field[&quot;image_two&quot;]);
          $image_three = strip_tags($get_empty_field[&quot;image_three&quot;]);
          $image_four = strip_tags($get_empty_field[&quot;image_four&quot;]);
          $image_five = strip_tags($get_empty_field[&quot;image_five&quot;]);
          global $identity;
  </code></pre>
  <p>The below is what I tried even though it didn't work. I already knew it won't work but I wanted to try it myself before asking a question. And the error is coming from the <code>$get_empty_field = $stmt-&gt;bind_result($stmt);</code></p>
  <pre><code>if (move_uploaded_file($_FILES['file_to_upload']['tmp_name'], $final_uploads_location)) {
      $firstname = '&quot;&quot;';
      $lastname = '&quot;&quot;';
      $stmt = $mysqli-&gt;prepare(&quot;select * from `vpb_uploads` where `username` = ?  and `firstname` = ? and `lastname` = ?&quot;);
      $stmt-&gt;bind_param('sss', $username, $firstname, $lastname);
      $stmt-&gt;execute();
      $stmt-&gt;store_result();
      if ($stmt-&gt;num_rows &lt; 1) {
          $date = 'date(&quot;d-m-Y&quot;)';
          $image_2 = &quot;''&quot;;
          $image_3 = &quot;''&quot;;
          $image_4 = &quot;''&quot;;
          $image_5 = &quot;''&quot;;
          $stmt = $mysqli-&gt;prepare(&quot;insert into `vpb_uploads` (`username`, `firstname`, `lastname`, `image_one`, `image_two`, `image_three`, `image_four`, `image_five`, `date`) values(?,?,?,?,?,?,?,?,?)&quot;);
          $stmt-&gt;bind_param('sssssssss', $username, $firstname, $lastname, $random_name_generated, $image_2, $image_3, $image_4, $image_5, $date);
          $stmt-&gt;execute();
          $stmt-&gt;close();
  
          $identity = &quot;image_one&quot;;
      } else {
          $get_empty_field = $stmt-&gt;bind_result($stmt);
          $image_one = strip_tags($get_empty_field[&quot;image_one&quot;]);
          $image_two = strip_tags($get_empty_field[&quot;image_two&quot;]);
          $image_three = strip_tags($get_empty_field[&quot;image_three&quot;]);
          $image_four = strip_tags($get_empty_field[&quot;image_four&quot;]);
          $image_five = strip_tags($get_empty_field[&quot;image_five&quot;]);
          global $identity;
  </code></pre>