2个sql插入语句在一个不起作用

时间:2018-06-13 13:39:22

标签: mysqli

我正在尝试使用在一个中准备的sql语句,以便它同时更新到表。我被告知,最好的方法是使用commit(),但我不能让它正常工作。到目前为止我有这个:

$con->autocommit(FALSE);

require_once(dirname(__FILE__).'/paypal.class.php');  

$p = new paypal_class;             

if ($p->validate_ipn() && !empty($p->ipn_data['payment_status']) && $p->ipn_data['payment_status'] == 'Completed') {



                    $mc_gross = $_POST['mc_gross'];
                    $payer_id = $_POST['payer_id'];
                    $payment_date = $_POST['payment_date'];
                    $first_name = $_POST['first_name'];
                    $last_name = $_POST['last_name'];
                    $payer_email = $_POST['payer_email'];
                    $payment_status = $_POST['payment_status'];
                    $payer_status = $_POST['payer_status'];
                    $address_name = $_POST['address_name'];
                    $address_country = $_POST['address_country'];
                    $address_zip = $_POST['address_zip'];
                    $address_state = $_POST['address_state'];
                    $address_city = $_POST['address_city'];
                    $address_street = $_POST['address_street'];
                    $mc_currency = $_POST['mc_currency'];
                    $address_status = $_POST['address_status'];
                    $charset = $_POST['charset'];
                    $num_cart_items = $_POST['num_cart_items'];
                    $payment_fee = $_POST['payment_fee'];
                    $payment_gross = $_POST['payment_gross'];
                    $transaction_subject = $_POST['transaction_subject'];
                    $ipn_track_id = $_POST['ipn_track_id'];




    $stmt = $con->prepare("INSERT into orders (mc_gross, payer_id, payment_date, first_name, last_name, payer_email, payment_status, payer_status, address_name, address_country, address_zip, address_state, address_city, address_street, mc_currency, address_status, charset, num_cart_items, payment_fee, payment_gross, transaction_subject, ipn_track_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");    
    $stmt->bind_param("ssssssssssssssssssssss", $mc_gross, $payer_id, $payment_date, $first_name, $last_name, $payer_email, $payment_status, $payer_status, $address_name, $address_country, $address_zip, $address_state, $address_city, $address_street, $mc_currency, $address_status, $charset, $num_cart_items, $payment_fee, $payment_gross, $transaction_subject, $ipn_track_id);
    $stmt->execute();
    $stmt->close();

    $stmt = $con->prepare("INSERT into order_items (mc_gross, ipn_track_id) VALUES (?,?)");    
    $stmt->bind_param("ss", $mc_gross, $ipn_track_id);
    $stmt->execute();
    $stmt->close();


    }

    $con->commit();
    $con->close();

非常感谢任何帮助

0 个答案:

没有答案