-1
我到我的數據庫連接給出表現出一定的誤差錯誤MySQL連接:mysqli_fetch_array()預計參數1被mysqli_result,布爾在
---/---/--- /功能/ function.php警告:mysqli_fetch_array()預計參數1被mysqli_result,在字符串中給定/第10行
<?php
$connection = mysqli_connect("localhost","root","password");
//getting the categories
function getCats(){
global $connection;
$get_cats = "select * from category";
$run_cats = mysqli_query($connection, $get_cats);
while ($row_cats = mysqli_fetch_array($run_cats)){
$cat_id = $row_cats['cat_id'];
$cat_title = $row_cats['cat_title'];
echo"<li><a href='#'>$cat_title</a></li>";
}
}
?>
它連接成功嗎?不太熟悉'mysqli'是否需要連接上的'db'名字? – chris85
爲什麼不'var_dump($ run_cats);'調試問題? 'mysqli_query'返回一個*字符串*而不是一個布爾值或對象是不太可能的。顯示真實/當前的代碼。 – mario
連接成功但顯示錯誤。這是真正的代碼 – Abeth