Check out system for Shopping Cart

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Can you please help with my checkout script. I have been getting errors as shown below:

Warning: mysqli_query() expects parameter 1 to be mysqli, object given in C:\wamp\www\draft\checkout.php on line 26

Warning: mysqli_affected_rows() expects parameter 1 to be mysqli, object given in C:\wamp\www\draft\checkout.php on line 28

Warning: mysqli_rollback() expects parameter 1 to be mysqli, object given in C:\wamp\www\draft\checkout.php on line 77
System error
Warning: mysqli_close() expects parameter 1 to be mysqli, object given in C:\wamp\www\draft\checkout.php on line 83

for the script

<?php

    include("mysql.class.php");

    include ("header.php");
   
   
   
    //include ("functions.php");
   
    $user = 1;
    $total = 178.93;
   
    include ("mysql_connect.php");
   
    //Turn off autocommit
   
    //mysql_autocommit($con, FALSE);
   
    //Add orders to the order table
   
    $sql = "INSERT INTO orders (user_id, total) VALUES ($user, $total)";
   
    $r = mysqli_query($con, $sql);
   
    if (mysqli_affected_rows($con)==1) {
   
    $oid = mysql_insert_id($con);
   
    //Insert the specific order contents into the database
   
    // prepare query
   
    $sql = "INSERT INTO order_contents(order_id, id, quantity, price)
   
        VALUES (?, ?, ?, ?)";
       
        $stmt = mysqli_prepare($con, $sql);
       
        mysqli_stmt_bind_param($stmt, 'iiid', $oid, $id, $qty, $price);
       
        //execute each query, count the total affected:
       
        $affected = 0;
       
        foreach ($_SESSION['cart'] as $id => $item){
       
        $qty = $item['quantity'];
        $price = $item['price'];
       
        mysqli_stmt_execute($stmt);
       
        $affected += mysqli_stmt_affected_rows($stmt);
       
        }
       
        mysqli_stmt_close($stmt);
       
        if ($affected ==count($_SESSION['cart'])) {
       
        mysqli_commit($con);
       
        echo'Thank you for your order';
       
        }else{
       
        mysqli_rollback($con);
       
        echo'Your order could not be processed';
       
        }
       
        }else{
       
        mysqli_rollback($con);
       
        echo'System error';
       
        }
       
        mysqli_close($con);
       
   
       
        include ("footer.html");
       
       
        ?>

Many Thanks




VEE
VEE




Windows Live Messenger just got better. Find out more!
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux