0
我在連接數據庫時遇到問題。請幫助這個代碼錯了什麼?連接php到mysqli數據庫錯誤
<?php
$con = mysqli_connect('localhost','root','','ecommerce');
//getting the categories
function getCats(){
global $con;
$get_cats="select * from categories";
$run_cats=mysqli_query($con, $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>";
}
}
//getting the brands
function getBrands(){
global $con;
$get_brands="select * from brands";
$run_brands=mysqli_query($con, $get_brands);
while($row_brands = mysqli_fetch_array($run_brands)){
$brand_id=$row_brands('brand_id');
$brand_title=$row_brands('brand_title');
echo "<li><a href='#'>$brand_title</a></li>";
}
}
?>
有什麼錯誤 – clearshot66
爲什麼你認爲* *的東西是錯誤的代碼?你想要解決什麼實際問題? – David
如果你有連接問題檢查錯誤,http://php.net/manual/en/mysqli.connect-error.php。 – chris85