I'm trying to make a login/register system and I keep getting the errors: Warning: mysql_query() expects parameter 2 to be resource, integer given in /home/roscapex/public_html/core/functions/users.php on line 8
Warning: mysql_result() expects at least 2 parameters, 1 given in /home/roscapex/public_html/core/functions/users.php on line 8
My code is:
<?php
function user_exists($username) {
$username = sanitize($username);
$query = mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username'");
return (mysql_result(mysql_query($query, 0) == 1) ? true : false);
}
?>
NOTE This might be a duplicate but I tried all the other relevant questions.