Mysql
 sql >> Database >  >> RDS >> Mysql

inserire la query utilizzando foreach loop che riceve un errore non rilevato:chiamata a una funzione membro execute() su booleano

cambialo in questo modo per separarlo dal coma.

$_query = "INSERT INTO ord_dets(Order_ID,custmer_ip,Resturant_ID,Resturant_name,City_name,
        Product_Id,Product_Name,Product_Price,item_sub) 
VALUES ";
        $_query_parts  = array();
        $sep ="";
        for($x=0;$x<count($OI); $x++){
        $_query_parts  = "$sep('" . $OI[$x] . "', '" . $ip[$x] . "','" . $_SESSION['rest_id'][$x] . "','" . $rest_name[$x] . "',
            '" . $City_name[$x] . "','" . $Product_Id[$x] . "','" . $product_name[$x] . "','" . $prod_price[$x] . "','" . $item_sub[$x] . "')";
        $sep=",";
        }
      $query_run = $dbc->prepare($_query);
       echo $_query;

        if (!$query_run->execute()) {
            $insertError = "There was an error inserting data: " . $query_run->error;
      print "affected rows:" . $query_run->affected_rows; //how many records affected?         

    }
  }