PHP MySQL error - mysql_num_rows () [duplicate]

0

I'm having trouble correcting this error, I do not know much about language (almost anything). The error that appears on the page is this:

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\EasyPHP-Devserver-17\eds-www\core\inc\user.inc.php on line 10

PHP:

<?php

function validate_credentials($user_name, $user_password){
$user_name = mysql_real_escape_string($user_name);
$user_password = sha1($user_password);

$result = mysql_query("SELECT 'user_id' FROM 'users' WHERE 'user_name' = 
'{$user_name}' AND 'user_password' = '{$user_password}'");

if (mysql_num_rows($result) != 1){
    return false;
}

return mysql_result($result, 0);
}

?>
    
asked by anonymous 19.11.2018 / 07:44

1 answer

0

Follow this example here because I think you forgot connection and without it nothing will be returned in your query ...

  

Example # 1 Example mysql_num_rows ()

<?php

$link = mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("database", $link);

$result = mysql_query("SELECT * FROM table1", $link);
$num_rows = mysql_num_rows($result);

echo "$num_rows Rows\n";

?>

site where I got the answer.

    
19.11.2018 / 11:10