title: How to check if mysql_query returned anything or not
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2973202/mysql-fetch-array-expects-parameter-1-to-be-resource-boolean-given-in-select">mysql_fetch_array() expects parameter 1 to be resource, boolean given in select</a>  </p>
  </blockquote>
  
  
  
  <p>So I am trying to check if the following query returns any result or not</p>
  
  <pre><code>  $numUsersSameRatingQuery="SELECT * `user ratings` WHERE  category='$category' AND categoryId='$categoryId' AND  `userAromaRating`&gt;0 ";
  
    $result=mysql_query($numUsersSameRatingQuery);
  
     $numResults=mysql_num_rows($result);
  
    if($numResults==0)
    {
     // do the INSERT INTO
    }
    else
    {
     //do the UPDATE SET
    }
  </code></pre>
  
  <p>However, the above returns the following error and the <code>if($numResults)</code> is executed anyway each time. In other words, I can never get the <code>else</code> block to run. </p>
  
  <p>Here is the error</p>
  
  <pre><code> Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\boozeDb\profileThis.php on line 141
  </code></pre>
  
  <p>Helps are appreciated.</p>