我有以下 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:\xampp\webdesktop\login.php on line 22
我了解该错误并尝试修复它并解决它但没有成功。是否可以在 PHP 中从 MySQL 中检索 INTEGER 值以及如何检索?
或者你能告诉我更好的方法来做到这一点。
感谢!