I am trying to use the following php code to see is a user is active, for loggin in purposes but I get errors.
The code:
[php]<?php
function user_exists($username) {
$username = sanitize($username);
$query = "SELECT COUNT(user_id
) FROM users
WHERE username
= $username
";
return (mysqli_query($query, 0) == 1) ? true : false;
}
?>[/php]
When I run the login page I get this error:
Warning: mysqli_query() expects parameter 1 to be mysqli, string given in C:\xampp\htdocs######\users.php on line 5
Being new to mysql / mysqli I would be greatful for any help in solving this problem.
Thanks is advance.