Fatal error: Uncaught Error: Call to a member function bind_param() on boolean in C:\xampp\htdocs….
I have re-typed the script many times and cant seem to find my misstep. Can someone please help?
if(isset($_POST['addOrderBTN'])){
$orderNo = $_POST['orderNo'];
$orderDate = $_POST['orderDate'];
$deliveryTime = $_POST['deliveryTime'];
$customerPhone = $_POST['customerPhone'];
$customerEmail = $_POST['customerEmail'];
$custFirstName = $_POST['firstName'];
$custLastName = $_POST['lastName'];
$custStreetAddress = $_POST['streetAddress'];
$custStreetDirection = $_POST['streetDirection'];
$custCity = $_POST['city'];
$custPostalCode = $_POST['postalCode'];
$custCountry = $_POST['country'];
$productName = $_POST['productName'];
$productPrice = $_POST['price'];
$productQuantity = $_POST['productQty'];
$deposit = $_POST['deposit'];
$subTotal = $_POST['subTotal'];
$depositTotal = $_POST['depositTotal'];
$tax1 = $_POST['tax1'];
$orderTotal = $_POST['orderTotal'];
$deliveyrInstrucitons =$_POST['deliveryInstructions'];
$orderComments = $_POST['orderComments'];
$sql = "INSERT INTO delivery_orders_tbl(orderNumber, orderDate, deliveryTime, customerPhone, customerPhone, customerEmail, firstName, lastName, streetAddress, streetDirection, city, postalCode, country, productName, productPrice, productQuantity, deposit, subTotal, depositTotal, tax1, orderTotal, deliveryDirections, orderComments) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
$stmt = $conn->prepare($sql);
//bind parameters
$stmt->bind_param("sssssssssssssdidddddss", $orderNo, $orderDate, $deliveryTime, $customerPhone, $customerEmail, $custFirstName, $custLastName, $custStreetAddress, $custStreetDirection, $custCity, $custPostalCode, $custCountry, $productName, $productPrice, $productQuantity, $deposit, $subTotal, $depositTotal, $tax1, $orderTotal, $deliveyrInstrucitons, $orderComments);
if($custFirstName !== ''){
$stmt->excute();
echo "Order No " .$orderNo. " Sucessfuly Added";
}else{
echo "Some error occured, try again.";
}
$stmt->close();
}
>Solution :
sql = "INSERT INTO delivery_orders_tbl(orderNumber, orderDate, deliveryTime, customerPhone, customerPhone, customerEmail, firstName, lastName, streetAddress, streetDirection, city, postalCode, country, productName, productPrice, productQuantity, deposit, subTotal, depositTotal, tax1, orderTotal, deliveryDirections, orderComments) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
customerPhone column is repeated twice and that means your sql query contains 23 columns and only 22 values to be submitted.