我试图获取包含空或空字段的行数,以便如果这个行数大于或等于1,用户会收到提醒,告诉他们完成这些记录,但是我收到了标题中提到的错误。SQL PHP错误:mysqli_num_rows()期望参数1为mysqli_result,布尔给定
代码:
function incompleteTechLog() {
include 'config.php';
// Connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM tbl_flights WHERE pilot_initial_post IS NULL OR = '' AND is_deleted = '0'"; // program allows for soft deleting so this must be included in the query
$result = $conn->query($sql);
$rows = mysqli_num_rows($result);
if ($rows >= 1) {
echo "<div class='alert alert-warning' role='alert'><strong>Minor Alert! </strong>" . $rows . " tech log(s) are incomplete. Please check all aircraft tech logs.</div>";
} else {
$conn = null;
}
}
任何帮助将不胜感激。
这个错误通常意味着有一个与SQL查询 –