警告:mysqli_stmt :: bind_result():绑定变量数与预准备语句中的字段数不匹配

时间:2012-05-29 01:50:04

标签: php mysqli

我正在尝试调用插入新记录并返回最后一个id的存储过程。 当我呼叫页面时,我收到上述错误,并引用第6行。

1. $Str = 'Hello world';
2. $parentId = 1;
3.  
4. $lastId = 0;
5. $statement = $con->prepare('call createRecordReturnsId( ? , ? )');
6. $statement->bind_param("si",$Str,$parentId);
7. $statement->bind_result($lastId);
8. $statement->execute();

PS。我使用MSQLI的原因是我需要执行多个create语句。

1 个答案:

答案 0 :(得分:0)

我只需要将bind语句(第7行)移到execute语句(第8行)之后

以下订单有效:

1. $Str = 'Hello world';
2. $parentId = 1;
3.  
4. $lastId = 0;
5. $statement = $con->prepare('call createRecordReturnsId( ? , ? )');
6. $statement->bind_param("si",$Str,$parentId);
7. $statement->execute();
8. $statement->bind_result($lastId);
相关问题