i am making a user login system through php i made the database made the connection made the form taking user name and password and storing in the variable
/// database connection code///
<?php
mysql_connect('localhost','root','#########');
mysql_select_db('scholarships_system');
?>
/////form data into variable/////
if(empty ($_POST)=== false){
$username = $_POST['username'];
$password = $_POST['password'];
if(empty($username)=== true || empty($password)=== true )
{
$errors[] = 'You need to enter a username and password';
}
else if (user_exists($username)=== false)
{$errors[] = 'we cant find that username have you registerd ?';
}
}
/////// function code ////
function user_exists($username){
return (mysql_result(mysql_query(" SELECT COUNT (`user_id`) FROM `users_login` WHERE `username` = '$username'"),0) == 1) ? true : false;
}
///if i call the function to check error occurs////
Warning: mysql_result() expects parameter 1 to be resource, boolean given in C:\wamp\www\login and registry\core\functions\users.php on line 6
////line 6 is////
return (mysql_result(mysql_query(" SELECT COUNT (`user_id`) FROM `users_login` WHERE `username` = '$username'"),0) == 1) ? true : false;
}