我一直在尝试像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