我一直在嘗試像MySQL一樣,但它不工作。這裏是我的代碼:如何檢查Mysqli查詢是否爲空?
<?php
$sql_st_check = "SELECT station_name FROM station WHERE station_code=".$station_code."";
$sql_st_query = mysqli_query($connect, $sql_st_check);
if ($sql_st_query && mysqli_num_rows($sql_st_query) > 0) {
} else {
$sql_st_insert = "
INSERT INTO station (id, station_code, station_name, station_title, url, datetime)
VALUES ('', '".$station_code."', '".$station_name."', '".$station_title."', '".$station_url."', '".$time."')";
$sql_st_query = mysqli_query($connect, $sql_st_insert);
}
?>
的可能的複製缺少的單引號[檢查,如果查詢結果爲空行mysqli](http://stackoverflow.com/questions/21258620/check-if-the-query-results-empty-row-mysqli) – Jadeye
但問題是不一樣的,我面對同一代碼的不同問題。 – shpwebhost