Php Msqli语句错误,未返回任何内容

Php Msqli语句错误,未返回任何内容,php,mysqli,Php,Mysqli,直接摘自mysqli书籍: <?php /* Prepared statement, stage 2: bind and execute */ $id = 1; if (!$stmt->bind_param("i", $id)) { echo "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error; } if (!$stmt->execute()) { echo "Ex

直接摘自mysqli书籍:

<?php
/* Prepared statement, stage 2: bind and execute */
$id = 1;
if (!$stmt->bind_param("i", $id)) {
    echo "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
}

if (!$stmt->execute()) {
    echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
}
?>

问题是$stmt->error不返回false上的任何内容


echo$stmt->错误不返回任何空白

如果bind_参数为false,我正在检查
$stmt->error
,但是bind_参数没有将
$stmt->error
设置为false。php手册声称它有,但它没有!如果执行不正确或参数类型的数量与参数的数量不匹配,bind_param将返回警告。

这在您的项目中可能不可行,但是您可以使用
PDO
并将其配置为在出现错误时抛出异常。@Tomasz这不是我现在的选项。您可能在脚本执行的早期出现了一个更严重的错误,您没有看到来自该错误的输出。在脚本的顶部,
error\u reporting(E\u ALL);ini设置(“显示错误”,1)始终在开发、测试或调试代码时。MySQLI对象在
prepare()
之前或期间也可能出现错误。假设对象是
$conn
,检查
echo$conn->error但您必须首先验证是否存在其他错误。您也可以,但我再次怀疑以前的错误。我找到了答案。如果bind_param为false,我正在检查$stmt->error,但是bind_param没有将$stmt->error设置为false。php手册声称它有,但它没有!如果执行不正确或参数类型的数量与参数的数量不匹配,bind_param将返回警告。手册的哪一部分声称在失败时设置了
$stmt->error