title: Mysql num rows issue
body: <p>I run this query to check if cat_name already exists it the mysql database... but it's show a warning messag.</p>
  
  <p>Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs......"</p>
  
  <pre><code>&lt;?php
  include("db.php");
  
  if(isset($_POST['cat_name']))
  {
  $cat_name = mysql_real_escape_string(htmlentities(trim($_POST['cat_name'])));   
  $err = array();
  
  $ch = mysql_query("SELECT cat_name FROM categories WHERE cat_name = '$cat_name' ");
  $num = mysql_num_rows($ch);
  
  if(empty($cat_name))
  $err[] = "Category field empty";
      elseif(is_numeric($cat_name))
      $err[] = "Category name should be string, ex: category name";
          elseif($num &gt; 0)
          $err[] = "Category name already exits, please choose another name";
              else
              {
                  if(strlen($cat_name) &lt; 3)
                  $err[] = "Category name at least 3 or more    
  characters";    
              }
  
  if(!empty($err))
  {
      foreach($err as $er)
      {
          echo "&lt;font color=red&gt;$er.&lt;/font&gt;";
      }   
  }
  else
  {
      $sql_insert = mysql_query("INSERT INTO categoires VALUES('',  
  '$cat_name')"); 
  
      if($sql_insert)
      {
          echo "Successfully inserted your category name";    
      }
      else
      {
          echo "Something is wrong to add your cateogory name";
          mysql_error();  
      }
  
  }
  
  
  }
  ?&gt;
  </code></pre>
  
  <p>Any idea?</p>