0
if anyone can help me error in the script I really appreciate, the error is as follows:
Fatal error: Call to Undefined method Pdostatement::bind_param() in
the code is this:
setlocale(LC_MONETARY,"en_US");
if(isset($_POST["id"])) {
foreach($_POST as $key => $value){
$product[$key] = filter_var($value, FILTER_SANITIZE_STRING);
}
$statement = app('db')->prepare("SELECT as_produtos.nome, as_produtos.preco FROM as_produtos WHERE id=? LIMIT 1");
$statement->bind_param('s', $product['id']);
$statement->execute();
$statement->bind_result($product_name, $product_price);
while($statement->fetch()){
$product["product_name"] = $product_name;
$product["product_price"] = $product_price;
if(isset($_SESSION["products"])){
if(isset($_SESSION["products"][$product['id']])) {
$_SESSION["products"][$product['id']]["product_qty"] = $_SESSION["products"][$product['id']]["product_qty"] + $_POST["product_qty"];
} else {
$_SESSION["products"][$product['id']] = $product;
}
} else {
$_SESSION["products"][$product['id']] = $product;
}
}
$total_product = count($_SESSION["products"]);
die(json_encode(array('products'=>$total_product)));
}
if(isset($_GET["remove_code"]) && isset($_SESSION["products"])) {
$product_code = filter_var($_GET["remove_code"], FILTER_SANITIZE_STRING);
if(isset($_SESSION["products"][$product_code])) {
unset($_SESSION["products"][$product_code]);
}
$total_product = count($_SESSION["products"]);
die(json_encode(array('products'=>$total_product)));
}
if(isset($_GET["update_quantity"]) && isset($_SESSION["products"])) {
if(isset($_GET["quantity"]) && $_GET["quantity"]>0) {
$_SESSION["products"][$_GET["update_quantity"]]["product_qty"] = $_GET["quantity"];
}
$total_product = count($_SESSION["products"]);
die(json_encode(array('products'=>$total_product)));
}
Thank you friend, your reply was of great help.
– Gabriel S Lessa