【发布时间】:2019-06-26 07:47:27
【问题描述】:
我想捕捉这个错误:
警告:mysqli_stmt::bind_param():类型定义字符串中的元素数与绑定变量数不匹配
解决方案是provided here,但由于某种原因它没有捕获错误。
$rc = $stmt->bind_param('iii', $x, $y, $z);
// bind_param() can fail because the number of parameter doesn't match the placeholders in the statement
// or there's a type conflict(?), or ....
if ( false===$rc ) {
// again execute() is useless if you can't bind the parameters. Bail out somehow.
die('bind_param() failed: ' . htmlspecialchars($stmt->error));
}
$rc即使绑定参数个数不匹配也返回1...
【问题讨论】:
-
我无法重现这个。如果
bind_param失败,我总是得到false结果 -
我支持这个^
-
因此,如果我编辑代码以删除参数: $rc = $stmt->bind_param('iii', $x, $y);我收到警告,无法检查 $rc 是否为假。可能是我误会了?
标签: php mysqli prepared-statement