title: check if row exists mysqli
body: <p>I am trying to check if row exists. I am getting </p>
  
  <p><code>Commands out of sync; you can't run this command</code></p>
  
  <p>I am getting this error because I added <code>$stmt-&gt;store_result();</code> if I remove that line <code>num_rows</code> doesn't return true. How can I check if the row exists?</p>
  
  <p>
  
  <pre><code>$title = urldecode($_GET['product-tit/']);
  $id = $_GET['item-id-pr'];
  $mydb = new mysqli('localhost', 'root', '', 'database');
  
  if(empty($title) || empty($_GET['item-id-pr'])){
  header('Location: products.php');
  exit();
  }
  else{
  $stmt = $mydb-&gt;prepare("SELECT * FROM products where title = ? AND id = ? limit 1 ");
  $stmt-&gt;bind_param('ss', $title, $id);
  $stmt-&gt;execute();
  $stmt-&gt;store_result();
  ?&gt; 
  &lt;div&gt;
  
  &lt;?php
  if($stmt-&gt;num_rows &lt; 1 )  {
       echo "not found";
       exit();
  
  
      } else{
  $result = $stmt-&gt;get_result();
   echo $mydb-&gt;error;
  
   while ($row = $result-&gt;fetch_assoc()) {
  
  
  
  
  
  echo wordwrap($row['price'], 15, "&lt;br /&gt;\n", true); 
       exit();
  }
  $mydb-&gt;close ();}}
  ?&gt;
  &lt;/div&gt;
  </code></pre>