-5
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in N:\ftp\compc\d10cn\Project\login1.php on line 51
The username you entered was not found.

^^ this is the error i keep getting, does anyone know what this means? or what would be wrong with line 51, which is:

$query = mysql_query ("SELECT * FROM users WHERE username = '$user'");

$numrows = mysql_num_rows($query);
if ($numrows == 1){
Ghost
  • 2,090
  • 20
  • 21
Niamh2
  • 9

2 Answers2

1

please try like so

    <?php 
    $link = mysql_connect("host", "username", "password");
    mysql_select_db("database", $link);

    $result = mysql_query("SELECT * FROM users WHERE username = '$user'", $link);
    $num_rows = mysql_num_rows($result);
    echo $num_rows

    ?>
Karthick Kumar
  • 2,360
  • 1
  • 15
  • 29
1

Check $query before passing it to mysql_fetch_array. You'll find that it's false because the query failed. See the [mysql_query][1] documentation for possible return values and suggestions for how to deal with them.

$query = mysql_query("SELECT * FROM users WHERE username = '$user'");

if($query === FALSE) {
    die(mysql_error()); // TODO: better error handling
}

$numrows = mysql_num_rows($query);
if ($numrows == 1){
Saurabh Sharma
  • 2,384
  • 4
  • 19
  • 37