我有以下代码,我想知道 mysqli_query 是否返回任何行,如果返回则返回错误.
I have the following code and I would like to know if mysqli_query returned any rows and if so return an error.
$result = mysqli_query($connection, "SELECT * FROM users");
if ($result == "") {
echo "No records found";
} else {
echo "There is at least one record in the database";
}
如果结果返回为空,我就会遇到麻烦.我已经尝试使用了几种东西,但如果没有找到任何东西,我无法弄清楚如何让它正常工作.
I'm having trouble if the results come back as empty. I've tried using several things and can't figure out how to get it work correctly if nothing is found.
使用 mysqli_num_rows 检查是否有任何行返回.
Use mysqli_num_rows to check if any rows were returned or not.
这篇关于检查 mysqli_query 是否返回任何值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
PHP、MySQL PDOException 的死锁异常代码?Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死锁异常代码?)
PHP PDO MySQL 可滚动游标不起作用PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滚动游标不起作用)
PHP PDO ODBC 连接PHP PDO ODBC connection(PHP PDO ODBC 连接)
使用 PDO::FETCH_CLASS 和魔术方法Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔术方法)
php pdo 只从 mysql 获取一个值;等于变量的值php pdo get only one value from mysql; value that equals to variable(php pdo 只从 mysql 获取一个值;等于变量的值)
MSSQL PDO 找不到驱动程序MSSQL PDO could not find driver(MSSQL PDO 找不到驱动程序)