title: mysqli binding fields in a prepared statement
body: <p>I have the following code, for which I get the error:</p>
  
  <p><strong>Warning</strong>: mysqli_stmt::bind_result() [mysqli-stmt.bind-result]: Number of bind variables doesn't match number of fields in prepared statement in file.</p>
  
  <p>If this is only a warning, shouldn't the code still work? I want to do a select * and display all the data except one field, which I want to bind and handle separately. Is there any way around, or a better method? My solution at the moment(untried) is to bind the correct amount of variables to the results with getRecords, and then bind separately as a different name with getHtml.</p>
  
  <p>What are the advanatges of binding, and is it necessary.</p>
  
  <pre><code>&lt;?php
  if (isset($_GET["cmd"]))
    $cmd = $_GET["cmd"]; else
    die("You should have a 'cmd' parameter in your URL");
  $id = $_GET["id"];
  $con = mysqli_connect("localhost", "user", "password", "db");
  if (!$con) {
      echo "Can't connect to MySQL Server. Errorcode: %s\n". mysqli_connect_error();
      exit;
  }
  $con-&gt;set_charset("utf8");
  echo "test outside loop";
  if($cmd=="GetSaleData") {
      echo "test inside loop";
      if ($getRecords = $con-&gt;prepare("SELECT SELECT Product_NO, Product_NAME, SUBTITLE, CURRENT_BID, START_PRICE, BID_COUNT, QUANT_TOTAL, QUANT_SOLD, ACCESSSTARTS, ACCESSENDS, ACCESSORIGIN_END, USERNAME, BEST_BIDDER_ID, FINISHED, WATCH, BUYITNOW_PRICE, PIC_URL, PRIVATE_AUCTION, AUCTION_TYPE, ACCESSINSERT_DATE, ACCESSUPDATE_DATE, CAT_DESC, CAT_PATH, COUNTRYCODE, LOCATION, CONDITIONS, REVISED, PAYPAL_ACCEPT, PRE_TERMINATED, SHIPPING_TO, FEE_INSERTION, FEE_FINAL, FEE_LISTING, PIC_XXL, PIC_DIASHOW, PIC_COUNT, ITEM_SITE_ID FROM Sales WHERE Product_NO = ?")) FROM SaleS WHERE PRODUCT_NO = ?")) {
          $getHtml = $con-&gt;prepare("SELECT PRODUCT_DESC FROM SaleS WHERE PRODUCT_NO = ?");
          $getHtml-&gt;bind_param("i", $id);
          $getHtml-&gt;execute();
          $getHtml-&gt;bind_result($PRODUCT_DESC);
          $getRecords-&gt;bind_param("i", $id);
          $getRecords-&gt;execute();
          $getRecords-&gt;bind_result($PRODUCT_NO, $PRODUCT_NAME, $SUBTITLE, $CURRENT_BID, $START_PRICE, $BID_COUNT, $QUANT_TOTAL, $QUANT_SOLD, $ACCESSSTARTS, $ACCESSENDS, $ACCESSORIGIN_END, $USERNAME, $BEST_BIDDER_ID, $FINISHED, $WATCH, $BUYITNOW_PRICE, $PIC_URL, $PRIVATE_Sale, $Sale_TYPE, $ACCESSINSERT_DATE, $ACCESSUPDATE_DATE, $CAT_DESC, $CAT_PATH, $COUNTRYCODE, $LOCATION, $CONDITIONS, $REVISED, $PAYPAL_ACCEPT, $PRE_TERMINATED, $SHIPPING_TO, $FEE_INSERTION, 
          $FEE_FINAL, $FEE_LISTING, $PIC_XXL, $PIC_DIASHOW, $PIC_COUNT, $ITEM_SITE_ID);
          while ($getRecords-&gt;fetch()) {
              // operations snipped for question
              echo "&lt;h1&gt;".$PRODUCT_NAME."&lt;/h1&gt;
  &lt;div id='leftlayer' class='leftlayer'&gt;
  &lt;p&gt;&lt;strong&gt;Username: &lt;/strong&gt;".$USERNAME."
  &lt;p&gt;&lt;strong&gt;Shipping to: &lt;/strong&gt; ". $country ."
  &lt;img src='./images/".$id.".jpg"' width='".$imageSize["width"]."' height='".$imageSize["height"]."'&gt;
  &lt;/div&gt;
  &lt;div id='rightlayer'&gt; 
  &lt;/div&gt;";
  //
  } 
  }
  }
  }
  </code></pre>
  
  <p>I would also like to know what is wrong with my img src statement..., I feel I am mising something elementary such as a slash or quote.</p>
  
  <p>edit: The code now displays an error after replace * with column names, however the while loop is never entered, and hence no actions are performed.</p>