2017-04-20 8 views
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>"; 
    } 
} 
?> 
+2

)何のエラー – clearshot66

+0

なぜあなたは*何かのコードが間違っている*と思いますか?あなたが解決しようとしている実際の問題は何ですか? – David

+0

接続の問題がある場合は、エラーを確認してください。http://php.net/manual/en/mysqli.connect-error.php。 – chris85

答えて

1

あなたは$row_cats -arrayと$row_brands -array間違ってアクセスしています。

使用[、代わりに(]

関連する問題