这个问题在这里已有答案:
您能否看一下这个演示,让我知道为什么我无法正确运行查询?我已经检查了数据库连接,它很好
<?php
$sql = "SELECT dt, events, eventtype FROM events";
$stmt = $mysqli->prepare($sql);
$stmt->execute();
$stmt->bind_result($dt,$events,$eventtype);
$stmt->store_result();
if($stmt->num_rows >0) {
$stmt->fetch();
}
else {
echo "Cant Find The data!";
}
$stmt->close();
$mysqli->close();
echo $dt;
echo $events;
echo $eventtype;
?>
得到这个错误
致命错误:在第113行的/srv/disk1/2555378/www/domain.net/index.php中调用boolean上的成员函数execute()
这意味着变量$mysqli
包含一个布尔值,可能是false
。
根据php文档,http://php.net/manual/en/mysqli.prepare.php,函数mysqli::prepare
将在出现错误时返回false
。
您应该使用错误变量来获取更多信息,例如:http://php.net/manual/en/mysqli.error.php