title: mysql_query() expects parameter 2 to be resource, boolean given in
body: <p>I looked at the other answers to problems similar to mine but cant seem to solve this. </p>
  
  <p>Here is the code.</p>
  
  <pre><code>  $connection = mysql_connect("localhost","root","starwars");
    $conn = mysql_select_db("project", $connection);
  
          // This code assumes $itemID is set to that of 
     // the item that was just rated. 
     // Get all of the user's rating pairs
     $sql = "SELECT DISTINCT r.itemID, r2.ratingValue - r.ratingValue 
                 as rating_difference
                 FROM rating r, rating r2
                 WHERE r.userID=$userID AND 
                         r2.itemID=$itemID AND 
                         r2.userID=$userID;";
  
     $db_result = mysql_query($sql, $conn);
     echo "The result is {$db_result}";
     $num_rows = mysql_num_rows($db_result)or die('Cannot Execute:'. mysql_error());
  </code></pre>
  
  <p>The error being displayed is:</p>
  
  <blockquote>
    <p>Warning: mysql_query() expects parameter 2 to be resource, boolean
    given in C:\xampp\htdocs\recomender\ratingfiles\class.rating.php on
    line 177</p>
  </blockquote>
  
  <p>Line 177 is </p>
  
  <pre><code>   $db_result = mysql_query($sql, $conn);
  </code></pre>
  
  <p>And if I echo <code>$conn</code> it gives the value of "1" which I thought was equal to true, thus boolean, any ideas?</p>