Possible Duplicate:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in select
I have the following MySQL Function:
DELIMITER $$
DROP FUNCTION IF EXISTS DoUsernameAndPasswordMatch$$
CREATE FUNCTION DoUsernameAndPasswordMatch(
UserLogin VARCHAR(20),
UserPass VARCHAR(20)
)
RETURNS BOOLEAN
BEGIN
DECLARE userCount BOOLEAN;
SELECT COUNT(*) INTO userCount
FROM Users_Login
WHERE Users_Login.UserLogin = UserLogin AND Users_Login.UserPass = SHA1(UserPass);
RETURN userCount;
END$$
DELIMITER ;
I invoke it from PHP like this:
$username_escaped = escapeMySQLParam($_POST["user"]);
$userpass_escaped = escapeMySQLParam($_POST["pass"]);
$mysql_query = "SELECT DoUsernameAndPasswordMatch('$username_escaped', '$userpass_escaped')";
$mysql_results = mysql_query($mysql_query);
$mysql_row = mysql_fetch_row($mysql_results);
But i get the following error:
Warning: mysql_fetch_row() expects parameter 1 to be resource,
boolean given in D:\xampp\webdesktop\login.php on line 22
I understand the error and tried to fixed it and workaround it with no success. Is it possible to retrieve INTEGER value from MySQL in PHP and how?
Or could you advice me better way to do this.
Thank!