title: MySQL Query with 3 AND
body: <p>I'm trying to get from database many fields to check user account.</p>
  
  <p>On form, user fill in code, pass and email.</p>
  
  <p>I need to check if user code exist, if password is correct, if email is correct and user have level 1 or 2 to go ahead.</p>
  
  <p>I'm trying with query below, but i'm redirected to error page.</p>
  
  <p>Where do I wrong?</p>
  
  <pre><code>$sql = "SELECT * FROM users WHERE (`user_code` = '". $user_code ."')
                                AND (`user_pass` = '". $user_pass ."')
                                AND (`user_email` = '". $user_email ."')
                                AND ((`user_level` = '1') OR (`user_level` = '2'))
                                LIMIT 1";
  
  $query = mysql_query($sql);
      if (mysql_num_rows($query) != 1) {
          header("Location: index.php?message=error"); exit;
  </code></pre>