having trouble with a mysql query
        Posted  
        
            by 
                chuck akers
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by chuck akers
        
        
        
        Published on 2012-10-30T10:59:11Z
        Indexed on 
            2012/10/30
            11:00 UTC
        
        
        Read the original article
        Hit count: 269
        
php
this keeps saying
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in directory here
the error is near the login_query variable, can someone help me fix it.
<?php
if (isset($_POST['login_username'], $_POST['login_password'])) {
  $login_username = trim(mysql_real_escape_string(htmlentities($_POST['login_username'])));
  $login_password = md5(trim(mysql_real_escape_string(htmlentities($_POST['login_password']))));
  if (!empty($login_username) && !empty($login_password)) {
    $login_query = mysql_query("SELECT user_id FROM username WHERE username='".$login_username."' AND password='".$login_password."'");
    if (mysql_num_rows($login_query)==1) {
      $user_id = mysql_result($login_query, 0, 'user_id');
      $_SESSION['user_id'] = $user_id;
      header('Location: index.php');
      die();
    }
  }}
    ?>
© Stack Overflow or respective owner