Creating a login system for something and am getting:
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in …/func/user.func.php on line 21
Here is my code:
function user_register($email, $name, $password) {
}
function user_exists($email) {
$email = mysql_real_escape_string($email);
$query = mysql_query("SELECT COUNT('user_id') FROM 'users' WHERE 'email' ='$email'");
//this is line 21:
return (mysql_result($query, 0) == 1) ? true : false;
}
Your SQL is full of syntax errors, single quotes are used to quote string literals, backticks (or double quotes in standard SQL) are used for identifiers. Try this:
You don’t need to quote any of those identifiers so don’t bother.
From the fine manual:
You probably want to add some error checking after you’ve fixed your SQL syntax errors.