我通过观看教程创建添加到购物车并显示错误警告:
mysqli_num_rows()期望参数1为mysqli_result,boolean 在第44行的C:\ xampp \ htdocs \ MyShop \ functions \ functions.php中给出。
我的代码如下:
function cart(){
if(isset($_GET['add_cart'])){
global $db;
$ip = getIpofCostumer();
$pro_id = $_GET['add_cart'];
$check_pro = "select * from cart where ip_add='$ip' AND p_id='$pro_id'";
$run_check = mysqli_query($db, $check_pro);
if (mysqli_num_rows($run_check)>0){
echo "";
} else {
$insert_pro = "insert into cart (p_id,ip_add) values ('$pro_id','$ip')";
$run_pro = mysqli_query($db, $insert_pro);
echo "<script>Window.open('cart.php','_self')</script>";
}
}
}
答案 0 :(得分:0)
检查您是否已将值分配给$db
$run_check = mysqli_query($db, $check_pro);