title: Why does this keep returning PHP ERROR Warning: mysql_num_rows() expects parameter 1 to be resource
body: <p>I have tryed to solve this but it has me stuck. any ideas help much appreciated. The book id is getting send to the url. url looks like /bookinfo.php?bookid=1
      
  
  <pre><code>if(isset($_GET['bookid'])){
      $id = preg_replace('#[^0-9]#i','', $_GET['bookid']);
      $sql = "SELECT DISTINCT bk.title AS Title, bk.year AS Year, bk.publisher AS Publisher, aut.authorname AS Author cat.category AS Category
           FROM book bk 
  
           JOIN book_category bk_cat 
           ON bk_cat.book_id = bk.bookid
  
           JOIN categories cat 
           ON cat.id = bk_cat.category_id
  
           JOIN books_authors bk_aut 
           ON bk_aut.book_id = bk.bookid
  
           JOIN authors aut
           ON aut.id = bk_aut.author_id
  
           WHERE bk.bookid='$id' LIMIT 1";
  
      $productCount = mysql_num_rows($sql);
      if($productCount&gt;0){
          while($row =mysql_fetch_array($sql)){
              $bookTitle = $row["Title"];
              $bookYear = $row["Year"];
              $bookPublisher = $row["Publisher"];
              $bookcopies = $row["copies"];
              $bookAvailableforreserve = $row["availableforreserve"];
              $bookDescription = $row["description"];
              $bookAuthor = $row["Author"];
              $bookCategory = $row["Category"];
  
  
          }
      }
  
  ?&gt;
  </code></pre>