I'm trying to produce a passfrase on the database with a function I found somewere. If i use the sql query directly on the database it produces a string as desired, but in my php page it gives the error:
"Fatal error: Uncaught Error: Call to a member function fetch_array() on boolean"
$query_rsCaptchaID = "DELIMITER $$
DROP FUNCTION IF EXISTS `randomPasswordGenerator` $$
CREATE FUNCTION `randomPasswordGenerator`(
) RETURNS varchar(64) CHARSET utf8
BEGIN
DECLARE charCount TINYINT(1) DEFAULT 0;
DECLARE charDiceRoll TINYINT(2);
DECLARE randomChar CHAR(1);
DECLARE randomPassword CHAR(64) DEFAULT '';
REPEAT
SET charCount = charCount + 1;
SET charDiceRoll = 1 + FLOOR(RAND() * 94);
IF (charDiceRoll <= 32)
THEN
SET randomChar = ELT(charDiceRoll,
'`', '~', '!', '@', '#', '$', '%', '^',
'&', '*', '(', ')', '-', '=', '_', '+',
'[', ']', '{', '}', '\\', '/', '|', '?',
';', ':', '\'', '\"', ',', '.', '<', '>');
ELSEIF (charDiceRoll >= 33)
AND (charDiceRoll <= 68)
THEN
SET charDiceRoll = charDiceRoll - 33;
SET randomChar = CONV(
charDiceRoll,
10, 36);
ELSE
SET charDiceRoll = charDiceRoll - 59;
SET randomChar = LOWER(
CONV(
charDiceRoll,
10, 36)
);
END IF;
SET randomPassword = CONCAT(randomPassword, randomChar);
UNTIL (charCount = 64)
END REPEAT;
RETURN randomPassword;
END $$
DELIMITER ;
SELECT randomPasswordGenerator() AS captchaID;";
$rsCaptchaID = mysqli_query($db,$query_rsCaptchaID);
$row_rsCaptchaID = $rsCaptchaID->fetch_array();
Any ideas anyone? I´m quite new on MySQLi, and not english speaking, sorry for errors.