This question already has an answer here:
I create add to cart by watching tutorials and its shows error Warning:
mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\MyShop\functions\functions.php on line 44.
My Code is as follows:
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>";
}
}
}
</div>