Thats what I get if I try to login, but if I try to register I get this:Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/a6713569/public_html/TGz/Content/Features/UAS/core/inc/user.inc.php on line 19
It's both the same code so the same error I cannot find >.<Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/a6713569/public_html/TGz/Content/Features/UAS/core/inc/user.inc.php on line 9
I compared your code with mine like 10 times but I cannot seem to find the error. Any help?
Here's my code:
<?php // Check if the username already exists. function user_exists($user){ $user = mysql_real_escape_string($user); $total = mysql_query("SELECT COUNT('user_id') FROM 'users' WHERE 'user_name' = '{$user}'"); return (mysql_result($total, 0) == '1') ? true : false; } // Check if the username and password are valid. function valid_credentials($user, $pass){ $user = mysql_real_escape_string(htmlentities($user)); $pass = sha1($pass); $total = mysql_query("SELECT COUNT('user_id') FROM 'users' WHERE 'user_name' = '{$user}' AND 'user_password' = '{$pass}'"); return (mysql_result($total, 0) == '1') ? true : false; } // Add new user to the database. function add_user($user, $pass){ $user = mysql_real_escape_string(htmlentities($user)); $pass = sha1($pass); mysql_query("INSERT INTO 'users' ('user_name', 'user_password') VALUES ('{$user}', '{$pass}')"); } ?>