请解决此问题。我把她困了很久。我没有在互联网上找到任何答案。请帮助我。
致命错误 :未捕获的错误:调用C:\ xampp \ htdocs \ Ecommerce \ includes \ sidebar.php:13中未定义的函数getPCats()堆栈跟踪:#0 C:\ xampp \ htdocs \ Ecommerce \ details.php(45):包含()抛出#1 {main} C:\ xampp \ htdocs \ Ecommerce \ includes \ sidebar.php 在线 13
functions.php
<?php
$db= mysqli_connect("localhost","root","","ecom_store") or die("Not connected.");
function getPCats(){
global $db;
$get_p_cats= "select * from product_categories";
$run_p_cats= mysqli_query($db,$get_p_cats);
while($row_p_cats=mysqli_fetch_array($run_p_cats)){
$p_cat_id = $row_p_cats['p_cat_id'];
$p_cat_title = $row_p_cats['p_cat_title'];
echo"
<li>
<a href='shop.php?p_cat=$p_cat_id'>$p_cat_title</a>
</>
";
}
}
?>
sidebar.php
<div class="panel panel-default sidebar-menu">
<div class="panel-heading">
<h3 class="panel-title">
Product Categories
</h3>
</div>
<div class="panel-body">
<ul class="nav nav-pills nav-stacked category-menu">
<?php getPCats();?>
</ul>
</div>
</div>