[英]PHP/MySQL Stored procedure issue
I am trying to add to my SQL database using a stored procedure, this procedure should add a unique_id, name, password and email address. 我正在尝试使用存储过程将其添加到我的SQL数据库中,该过程应添加一个unique_id,名称,密码和电子邮件地址。
I am using the following code: 我正在使用以下代码:
//Enter the valid data into the database
$username = filter_input(INPUT_POST, 'Username', FILTER_SANITIZE_STRING);
$encrypted_password = filter_input(INPUT_POST, 'Password', FILTER_SANITIZE_STRING);
$email = filter_input(INPUT_POST, 'Email', FILTER_SANITIZE_STRING);
$uuid = uniqid('', true);
$insertUser = mysqli_query($conn, "Call userInsert('$uuid', '$username','$encrypted_password', '$email')");
if(! $insertUser )
{
die('Error: ' . $conn->error);
}
else
{
echo "Success";
}
And this is my stored procedure: 这是我的存储过程:
$insertIntoUsers = "
CREATE PROCEDURE userInsert(unique_id VARCHAR(23), name VARCHAR(50), encrypted_password VARCHAR(80), email VARCHAR(50))
BEGIN
INSERT INTO users(unique_id, name, encrypted_password,email) values(unique_id, name,encrypted_password,email);
END";
I want it to take four field but I get the following error when I try to sign up 我希望它占用四个字段,但是尝试注册时出现以下错误
Error: Incorrect number of arguments for PROCEDURE users.userInsert; expected 3, got 4
Anyone know whats causing this? 有人知道是什么原因造成的吗? Saying it only wants three arguments, but I have specified four? 说它只需要三个参数,但是我指定了四个?
managed to sort it 设法排序
I had the same procedure stored before with 3 arguments, when I added the fourth argument, it never updated, so I dropped the procedure first using: 我以前用3个参数存储了相同的过程,当我添加第四个参数时,它从未更新,因此我首先使用以下命令删除了该过程:
drop procedure users.userInsert;
and ran the program again, everything worked then 然后再次运行该程序,然后一切正常
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.