Possible Duplicate:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in select
我有以下 MySQL 函数 :
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 ;
我从PHP这样引用:
$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);
但我有以下错误:
Warning: mysql_fetch_row() expects parameter 1 to be resource,
boolean given in D:xamppwebdesktoplogin.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?
或者你可以建议我 更好的方法做到这一点。
谢啦!