Below is my code. I get this error
Fatal error: Uncaught Error: Call to a member function bindParam() on bool
<?php
require("connectProduct.php");
Get these $_POST from another PHP. Please let me know how can I change?
if (isset($_POST)){
$brand_name = trim($_POST['brandname']);
$product_type = trim($_POST['type']);
$product_name = trim($_POST['Prodname']);
$color = trim($_POST['color']);
$image = trim($_POST['image']);
$id = (int) $_POST['id'];
$quantity = (int) ($_POST['qty']);
$price = (float) $_POST['price'];
try {
$sql = 'INSERT INTO items_table(id, brand_name, product_type,name,price,color,image,quantity)
VALUES(:id, :brand_name, :product_type, :product_name, :price, :color, :image, :quantity)';
$stmt = $conn->prepare($sql);
"Uncaught Error: Call to a member function bindParam() on bool" in below line
$stmt->bindParam(":id", $id);
$stmt->bindParam(":brand_name", $brandname);
$stmt->bindParam(":product_type", $prodtype);
$stmt->bindParam(":product_name", $prodname);
$stmt->bindParam(":price", $price);
$stmt->bindParam(":color", $color);
$stmt->bindParam(":image", $image);
$stmt->bindParam(":quantity", $qty);
$stmt->execute();
if ($stmt->rowCount()) {
header("Location: create.php?status=created");
exit();
}
header("Location: create.php?status=fail_create");
exit();
} catch (Exception $e) {
echo "Error " . $e->getMessage();
exit();
}
} else {
header("Location: create.php?status=fail_create");
exit();
}
?>