我收到一條通知:試圖獲取if ($resCategory->num_rows > 0)
行中非對象的屬性。我可以知道這裏有什麼錯誤嗎?注意:試圖獲取非對象的屬性
<?php
function categoryParentChildTree($parent = 'L1', $spacing = '', $category_tree_array = '') {
global $MySQLi_CON;
$parent = $MySQLi_CON->real_escape_string($parent);
if (!is_array($category_tree_array))
$category_tree_array = array();
$sqlCategory = "SELECT * FROM users where enrolled_id = $parent ORDER BY enrolled_id ASC";
$resCategory=$MySQLi_CON->query($sqlCategory);
if ($resCategory->num_rows > 0) {
while($rowCategories = $resCategory->fetch_assoc()) {
$category_tree_array[] = array("id" => $rowCategories['enroller_id'], "name" => $spacing . $rowCategories['user_name']);
$category_tree_array = categoryParentChildTree($rowCategories['enroller_id'], ' '.$spacing . '- ', $category_tree_array);
}
}
return $category_tree_array;
}
?>
1.什麼是MYSQLI_CON設置爲 2.我建議在代碼中使用多個換行符,例如單獨的「IFS」從追加新行代碼的其餘 –
你沒有檢查是否存在故障現在正在引起進一步的失敗。您不應該假設數據庫操作成功。 'if($ resCategory === false){die(mysqli_error($ MySQLi_CON)); }'。 – HiDeo
好吧,我在'where子句'中收到未知列'L1'的錯誤。我的L1存在,它爲什麼顯示錯誤? – stackoverflow