PHP PDO Multiple Prepare Statement

user3418528

This Code did not work. I am new in php pdo. This statement works only for first stmp then other does not work.

Code:

try {   
    $db->beginTransaction();

    $stmp = $db->prepare("UPDATE jeslot_customer SET cust_outstinding=:totaloutstanding WHERE cust_name=:custname");
    $stmp->execute(array(':totaloutstanding' => $tout,':custname' => $custname));

    $stmp1 = $db->prepare("UPDATE jeslot_products SET opening_stock=:clstock WHERE product_name=:name1");
    $stmp1->execute(array(':clstock' => $clstock,':name1' => $name1));


    $stmt2 = $db->prepare('INSERT INTO jeslot_sales (username, sell_date, invoiceid, product_name, product_weight, sell_price, sell_qty, sell_freeqty, totalqty, sell_amount, customerid, customer_name, subtotal, discount, dis_amount, grandtotal, payment, balance, due_date, payment_mode, cheque_no, cheque_bank, description, countid, profitloss) VALUES (:uname, :selldate, :invoice ,:sname, :pkg, :srate, :sqty, :sfreeqty, :totalqty, :samount, :custid, :custname, :subtotal, :discount, :dis_amount, :payable, :payment, :balance, :duedate, :payment_mode, :cno, :bname, :description, :countid, :profit)');

    $stmt2->execute(array(
    ':uname' => $username,
    ':selldate' => $selldate,
    ':invoice' => $bill_no,
    ':sname' => $name1,
    ':pkg' => $pkg,
    ':srate' => $rate,
    ':sqty' => $quantity,
    ':sfreeqty' => $freequantity,
    ':totalqty' => $totalqty,
    ':samount' => $total,
    ':custid' => $custid,
    ':custname' => $custname,
    ':subtotal' => $subtotal,
    ':discount' => $discount,
    ':dis_amount' => $dis_amount,
    ':payable' => $grandtotal,
    ':payment' => $payment,
    ':balance' => $balance,
    ':duedate' => $duedate,
    ':payment_mode' => $mode,
    ':cno' => $cno,
    ':bname' => $bname,
    ':description' => $description,
    ':countid' => ($i+1),
    ':profit' => $profit
    ));

    $db->commit();
    $db->rollback();

} catch(PDOException $e) {

    $error[] = $e->getMessage();
}
Kevin Joymungol

Should not this statement

$stmp1->execute(array(':clstock' => $clstock,':name1' => $name1));

be

$stmp1->execute(array(':clstock' => $clstock,':product_name' => $name1));

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

php pdo prepare statement dynamic filter

From Dev

CakePHP PDO prepare statement

From Dev

PHP PDO prepare and execute

From Dev

PDO prepare statement search error

From Dev

PDO prepare statement and match against in boolean mode

From Dev

check if empty in php prepare statement

From Dev

check if empty in php prepare statement

From Dev

PHP PDO Undefined method DatabaseHandler::prepare()

From Dev

What is wrong with my code, mysql, PDO prepare delete statement?

From Dev

PHP PDO statement to filter records

From Dev

php - mysqli prepare statement error - procedure style

From Dev

PHP prepare statement insert too many in foreach

From Dev

PHP prepare statement insert too many in foreach

From Dev

Prepare statement prepare error

From Dev

php-mysql-pdo: execute not working after prepare when inserting

From Dev

Call to a member function prepare() on a non-object in PDO using PHP

From Dev

PHP's PDO prepared statement: am I able to use one placeholder multiple times?

From Dev

multiple PDO insert with single statement not working

From Dev

PDO MySQL SELECT with multiple criteria within an IF statement

From Dev

Selecting multiple rows in a Select statement using PDO

From Dev

PDO prepared statement in UPDATE Multiple ID

From Dev

multiple INSERTS and keeping PDO prepared statement security

From Dev

PDO multiple parameter binding for prepared statement

From Dev

PHP PDO Multiple image INSERT

From Dev

PHP PDO Multiple Table join

From Dev

PDO : prepare with bindvalue and like %

From Dev

PDO prepare fails

From Dev

"prepare" PDO function error

From Dev

Multiple update query in single prepare execute statement mysql

Related Related

HotTag

Archive