** SOLVED **
** I made a stupid typo in the function sanitize. I created her as sanitze. Thank you **
If anybody could help me, I would appreciate it very much. I am learning the database interaction and have a User in my database called 'George'.
To check if he exists I have this function:
function sanitze($data) {
return mysql_real_escape_string($data);
}
function user_exists($username) {
$username = sanitize($username);
$query = mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username'");
// Check the result of the query (COUNT) and return either true or false
return (mysql_result($query, 0) == 1) ? true : false;
}
And then I am checking the Username with this If statement:
if(user_exists('George') === true) {
echo 'User exists';
} else {
echo 'User doesn\'t exist';
} die ();
But I don't get any results. I found this Thread: PHP username check function not working
And I am currently working on it, but haven't found any solution yet.
If anyone knows the answer. It would be great.
SELECT username FROM users where name = ???....WHERE username = '" . $username . "'"