【发布时间】:2017-05-15 06:58:50
【问题描述】:
我正在尝试获取包含 null 或空字段的行数,以便如果此行数大于或等于 1,则会提示用户完成这些记录(s ),但是我得到了标题中提到的错误。
代码:
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 查询存在问题