我有存储过程:
DELIMITER $$
CREATE PROCEDURE `SignUp`(
IN p_emailid VARCHAR(100),
IN p_pwd VARCHAR(100)
)
BEGIN
Insert into Users(
emailid,
pwd
)
values(
p_emailid,
p_pwd
);
END
在PHP页面中:
include("config.php");
try{
$stmt = $DBH->prepare('CALL SignUp(:p_username, :p_password)');
$stmt->bindParam(':p_username','Hiiiiiiiiii',PDO::PARAM_STR,100);
$stmt->bindParam(':p_password','1111111111111',PDO::PARAM_STR,100);
$stmt->execute();
}
catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
我得到异常:致命错误:无法通过引用传递参数2
哪里出错了?请帮忙。
答案 0 :(得分:0)
嗯,这正是它所说的。您不能将引用传递给值,只能传递给变量。你需要重写代码,如:
$username = 'Hiiiiiiiiii';
$password = '1111111111111';
$stmt->bindParam(':p_username', $username, PDO::PARAM_STR,100);
$stmt->bindParam(':p_password', $password, PDO::PARAM_STR,100);
祝你好运!