function cart(){
if (isset($_GET['add_cart'])) {
global $config;
$ip=getIp();
$pro_id=$_GET['add_cart'];
// checking if user already insert that product to cart
$sql="SELECT * FROM cart WHERE ip_add='$ip' AND p_id='$pro_id' " ;
$run_check=mysqli_query($config,$sql);
if(mysqli_num_rows($run_check)>0) {
echo "";
}
else{
$insert="INSERT into cart (p_id,ip_add) VALUES('$pro_id,$ip')";
$run=mysqli_query($config,$insert);
echo "<script>window.open('index.php','_blank')</script>";
}
}
}
我在mysqli_num_rows上遇到错误,它说mysqli_num_row需要两个类似的参数
答案 0 :(得分:2)
您需要为每个值添加单引号。 Reference
$insert="INSERT into cart (p_id,ip_add) VALUES('$pro_id','$ip')";