Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Keep getting "Fatal error: Uncaught Error: Call to a member function bind_param()"

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();
        
        
    }

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading