即时通讯试图从2个单独的表中查看数据,但出现此错误:
"Notice: Trying to get property of non-object in D:\xampp\htdocs\testsubject\User\inventory.php on line 18"
这是我的PHP代码:
$sql = "SELECT storage_details.itemCODE,storage_details.pckgeID,storage_details.cndition,storage_details.duration,pckge_info.price,storage_details.status
FROM storage_details
INNER JOIN pckge_info
ON storage_details.pckgeID=pckge_info.pckgeID";
$result = $link->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "itemcode: " . $row["itemCODE"]. " - packageid: " . $row["pckgeID"]. "condition: " . $row["cndition"]. "duration: " . $row["duration"]. " status: " . $row["price"]. " " . $row["status"]."<br>";
}
} else {
echo "0 results";
}
mysql_free_result($result);
您的查询很可能返回数据库错误。num_rows正在尝试评估一个空对象。让您的脚本死于错误并返回消息。一旦找出错误的地方,这将为您指明正确的方向。
if ($result === false) { die(mysql_error($link)); }
更新:阅读您的评论后,似乎pckge_info.pckgeID列可能不存在。仔细检查以确保您正在为查询的表调用正确的列名。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句