title: "Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given" error while trying to create a php shopping cart
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2973202/php-error-mysql-fetch-array-expects-parameter-1-to-be-resource-boolean-given">PHP Error: mysql_fetch_array() expects parameter 1 to be resource, boolean given</a>  </p>
  </blockquote>
  
  
  
  <p>This is the code I have in my <code>product.php</code>, every time I click on a product from the home page it comes up with the warning below:</p>
  
  <pre><code>if ( isset( $_GET['ID'] ) ) {
      $product_id = $_GET['ID'];
      $query = "SELECT Name, Genre, Price, Year, Picture FROM Products";
      $result = mysql_query( $query );
  
      while ( $row = mysql_fetch_array( $result, MYSQL_NUM ) ) {
          echo "&lt;div&gt;&lt;p&gt;Name: $row[0]&lt;/p&gt;&lt;p&gt;Genre: $row[1]&lt;/p&gt;&lt;p&gt;Price: $row[2]&lt;/p&gt;&lt;p&gt;Year: $row[3]&lt;/p&gt;&lt;/div&gt;";
      }
      echo "&lt;div&gt;&lt;a href=\"cart.php?action=add&amp;product=$product_id\"&gt;add to basket&lt;/a&gt;&lt;/div&gt;";
  }
  </code></pre>
  
  <p>and I get the warning:</p>
  
  <blockquote>
    <p>Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/cart/product.php on line 12</p>
  </blockquote>