我有以下 PHP,它基本上得到了 MySQL 查询的结果:
$q2 = "SELECT FIELD FROM TABLENAME WHERE ID = 1;";
$con = new mysqli($server, $user, $pass);
if (mysqli_connect_errno())
{
$error = mysqli_connect_error();
exit();
}
else
{
$res = mysqli_query($con, $q2);
if ($res)
{
while($row = mysqli_fetch_assoc($res))
{
PRINT "THERE WAS A RESULT HERE: ";
}
}
else
{
$error = mysqli_error();
exit();
}
mysqli_free_result($res);
};
mysqli_close($con);
但有时,它会返回一个空值。这是有效的,基于父应用程序的工作方式,但我怎样才能检测到空行并返回“这是一个空行:”?