Search code examples
phpmysqlmysql-num-rows

mysql_num_rows PHP


elseif(isset($_POST['submit']))
{
    // Look for their user
    $lookuser = mysql_query("SELECT * FROM `users` WHERE username='". mysql_escape_string($_POST['username']) ."'");
    // If we find a row
    if(mysql_num_rows($lookuser) > 0)

But my else for that, echos: An error has occured. <br> If you are sure you entered your username correctly, please contact an administrator.

I've tried to echo $_POST['username']; all works out fine. I've made sure my user exists, that works out fine.

The PHP error I get: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in password.php on line 23


Solution

  • You probably have an error in your sql query. To be sure of that, echo after your mysql_query mysql_error().