Php 是否插入到查询中,并期望有多个结果?

Php 是否插入到查询中,并期望有多个结果?,php,sql,insert,mysqli,Php,Sql,Insert,Mysqli,我有一个mysqli函数,它在表中插入一行。我正在找回错误 Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement 这对我来说很奇怪,因为我认为insert nto返回true或false。下面是使用sql语句的函数 function add_project_deadline ($mysqli, $project_id,

我有一个mysqli函数,它在表中插入一行。我正在找回错误

Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of 
fields in prepared statement
这对我来说很奇怪,因为我认为insert nto返回true或false。下面是使用sql语句的函数

function add_project_deadline ($mysqli, $project_id, $deadline) {


if ($stmt = $mysqli->prepare("INSERT INTO `project_deadline` (project_id, deadline) 
    VALUES (?, ?)")){
    $stmt->bind_param('is', $project_id, $deadline);
    $stmt->execute();
    $stmt->bind_result($return);
    $stmt->close();
    return $return;
} else {return false;}  

}

我的问题是为什么我会得到这个绑定结果错误,以及如何修复它。

因为您正在执行一个没有任何结果的
插入
查询,所以您不需要或使用
绑定结果
来获取数据
bind\u result
用于绑定SELECT语句中使用的列

mysqli\u stmt::execute()
在成功时返回
true
,在失败时返回
false
,因此只需将其值赋给
$return
变量即可

如果
execute()
返回false,则
INSERT
语句由于某种原因失败。如果返回
true
,则
INSERT
成功,您可以通过查看语句对象的
mysqli\u stmt::$infected\u rows
属性来确定插入的行数


这就是为什么你会犯这样的错误,希望能有所帮助。您可以在的手册页上找到这些信息的大部分。

首先阅读错误/警告消息:-1以帮助鼓励此过程。现在,为什么会这样说?什么样的更改可以“修复”它?我确实读过错误消息。我一直认为,如果它返回true,那么就会有一个结果,您可以绑定到一个变量。除非你不能,如果是这样,我怎么知道查询通过了?如果我在这一点上错了,那么我是否应该假设insert into查询返回多个结果?我真的不知道。我只是想得到一些启示和解释,说明insert into在true或false上返回什么,以及当使用mysqli进行查询时如何返回该值。类似的问题:至于insert是否有效,您可以检查