如何修复:PDOStatement::execute() 期望参数 1 为数组,第 64 行 C:\wamp64\www\invoiceTem01-Create.php 中给出的字符串

How to fix : PDOStatement::execute() expects parameter 1 to be array, string given in C:\wamp64\www\invoiceTem01-Create.php on line 64

<?php
    if($_POST){
        // include database connection
        include database.php;

        try{

            // insert query 01
            $query = "INSERT INTO invoice_master SET  y_sign=:y_sign, o_sign=:o_sign, tel=:tel, date=:date, terms=:terms, g_weight=:g_weight, n_weight=:n_weight, nop=:nop, payment=:payment, total=:invoice_total";


            // prepare query for execution
            $stmt = $con->prepare($query);

            // posted values
            $y_sign=htmlspecialchars(strip_tags($_POST['y_sign']));
            $o_sign=htmlspecialchars(strip_tags($_POST['o_sign']));
            $tel=htmlspecialchars(strip_tags($_POST['tel']));
            $terms=htmlspecialchars(strip_tags($_POST['terms']));
            $g_weight=htmlspecialchars(strip_tags($_POST['g_weight']));
            $n_weight=htmlspecialchars(strip_tags($_POST['n_weight']));
            $nop=htmlspecialchars(strip_tags($_POST['nop']));
            $payment=htmlspecialchars(strip_tags($_POST['payment']));

            $invoice_total=htmlspecialchars(strip_tags($_POST['invoice_total']));


            // bind the parameters
            $stmt->bindParam(':y_sign', $y_sign);
            $stmt->bindParam(':o_sign', $o_sign);
            $stmt->bindParam(':tel', $tel);
            $stmt->bindParam(':date', $date);
            $stmt->bindParam(':terms', $terms);
            $stmt->bindParam(':g_weight', $g_weight);
            $stmt->bindParam(':n_weight', $n_weight);
            $stmt->bindParam(':nop', $nop);
            $stmt->bindParam(':payment', $payment);

            $stmt->bindParam(':invoice_total', $invoice_total);

            // specify when this record was inserted to the database
            $date=date('m-d-Y');
            /* $stmt->bindParam(':created', $created); */

            // Execute the query
            if($stmt->execute()){
                $id = $con->lastInsertId($query);

                echo "New record created successfully. Last inserted Invoice ID is: " . $id."/2019/2020";
                $query1 = "UPDATE invoice_master SET invoice_no='$id/2019/2020' , invoice_name='TEMP01' WHERE $id";
                if ($stmt->execute($query1)){

                }

            }else{
                echo "<div class='alert alert-danger'>Record In Error state.</div>";
            }

        }
            // show error
        catch(PDOException $exception){
            die('ERROR: ' . $exception->getMessage());
        }
    }
    ?>

我想根据第一个 insert raw 更新 invoice_no & invoice_name。 当我们将发票详细信息插入 table 我想生成自己的发票编号并将其插入 table 时,我创建了此代码。我有一个 table,它可以添加原始倍数,所以我需要将 table 数据插入 table 如果您是先生,请告诉我如何做这些事情..

您正在使用 PDOStatement::execute():

$query1 = "UPDATE invoice_master SET invoice_no='$id/2019/2020' , invoice_name='TEMP01' WHERE $id";
    if ($stmt->execute($query1)){

但是如果您想 运行 查询而不获取结果,则必须使用 PDO::query(), if you want to create a new query or PDO::exec():

$query1 = "UPDATE invoice_master SET invoice_no='$id/2019/2020' , invoice_name='TEMP01' WHERE $id";
    if ($con->exec($query1)){