dongnuo4594 2017-04-20 18:35
浏览 69

将php连接到mysqli数据库错误

i am having a problem in connecting this with the database. Please help whats wrong on this code?

<?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>";
    }
}
?>
  • 写回答

1条回答 默认 最新

  • douwei4370 2017-04-20 18:54
    关注

    You are accessing the $row_cats-Array and $row_brands-Array wrong.

    Use [and ] instead of ( and )

    评论

报告相同问题?

悬赏问题

  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数