-1
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>";
        }

    }
}

i am getting error on mysqli_num_rows it says mysqli_num_row expects two parameter something like that

Professor Abronsius
  • 33,063
  • 5
  • 32
  • 46
root
  • 3
  • 2

1 Answers1

2

You need to add single quote for each value. Reference

$insert="INSERT into cart (p_id,ip_add) VALUES('$pro_id','$ip')";
Ayaz Ali Shah
  • 3,453
  • 9
  • 36
  • 68