php - 如何修复非对象错误的属性“num_rows”
问题描述
if ($result-> num_rows > 0) {
while($row = $result->fetch_assoc()) {
code here..}`
以上是我的 php 代码,但服务器总是说下面的错误。
试图在...中获取非对象的属性“num_rows”
解决方案
试试这个>
$result = $conn->query($sql);
if($result){
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
code here..}`
}
推荐阅读
- rust - 处理用户输入
- java - 如何在 Spring 中使用 MongoDB 强制执行唯一字段
- sql - 使用较少分区键的 SQL 查询表是否更快?
- java - 在maven项目中将selenium 2.xx升级到4.0.0并修复错误
- amazon-web-services - AWS API 网关 MTLS
- python - 无法对替换密码进行编码
- javascript - Chartjs 3.x - 如何在只有 1 个数据集的水平条形图两侧复制 X 轴?
- c# - DevExpress 集合过滤器和BetweenOperator
- django - 使用 MongoDB 在 Django Admin 中记录主键错误
- vue.js - 如何正确设置产品的 sw-entity-multi-select 字段并将它们保存到您的扩展