title: Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in php:74
body: <pre><code> if(isset($_POST[&quot;create_invoice&quot;]))
    { 
      $sub_total = 0;
      $discount = 0;
      $total_after_discount = 0;
  
      $statement = $conn-&gt;prepare(&quot;
        INSERT INTO tbl_medlab 
          (order_no, order_date, order_receiver_name, order_receiver_address, sub_total, discount, total_after_discount,order_datetime)
          VALUES (:order_no, :order_date, :order_receiver_name, :order_receiver_address, :sub_total, :discount, :total_after_discount, :order_datetime)
      &quot;);
      $statement-&gt;execute(
        array(
            ':order_no'               =&gt;  trim($_POST[&quot;order_no&quot;]),
            ':order_date'             =&gt;  trim($_POST[&quot;order_date&quot;]),
            ':order_receiver_name'          =&gt;  trim($_POST[&quot;order_receiver_name&quot;]),
            ':order_receiver_address'       =&gt;  trim($_POST[&quot;order_receiver_address&quot;]),
  
            ':sub_total'       =&gt;  $sub_total,
            ':discount'           =&gt;  $discount,
            ':total_after_discount'        =&gt;  $total_after_discount,
            ':order_datetime'           =&gt;  date(&quot;Y-m-d&quot;)
        )
      );
  
    $statement = $conn-&gt;query(&quot;SELECT LAST_INSERT_ID()&quot;);
        $order_id = $statement-&gt;fetchColumn();
  
        for($count=0; $count&lt;$_POST[&quot;total_item&quot;]; $count++)
        {
          $sub_total = $sub_total + floatval(trim($_POST[&quot;order_item_actual_amount&quot;][$count]));
  
  
          $discount = $discount + floatval(trim($_POST[&quot;discount_amount&quot;][$count]));
  
          $total_after_discount = $total_after_discount + floatval(trim($_POST[&quot;order_item_final_amount&quot;][$count]));
  
          $statement = $conn-&gt;prepare(&quot;
            INSERT INTO tbl_medlab_item 
            (order_id,item_type, item_name, order_item_quantity, order_item_price, order_item_actual_amount, discount, discount_amount, order_item_final_amount)
            VALUES (:order_id, :item_type, :item_name, :order_item_quantity, :order_item_price, :order_item_actual_amount, :discount, :discount_amount, :order_item_final_amount)
          &quot;);
  
          $statement-&gt;execute(
            array(
              ':order_id'               =&gt;  $order_id,
              ':item_name'              =&gt;  trim($_POST[&quot;item_name&quot;][$count]),
              ':order_item_quantity'          =&gt;  trim($_POST[&quot;order_item_quantity&quot;][$count]),
              ':order_item_price'           =&gt;  trim($_POST[&quot;order_item_price&quot;][$count]),
              ':order_item_actual_amount'       =&gt;  trim($_POST[&quot;order_item_actual_amount&quot;][$count]),
  
              ':discount'         =&gt;  trim($_POST[&quot;discount&quot;][$count]),
              ':discount_amount'       =&gt;  trim($_POST[&quot;discount_amount&quot;][$count]),
  //ERROR PART START HERE
              ':order_item_final_amount'      =&gt;  trim($_POST[&quot;order_item_final_amount&quot;][$count]) 
  //ERROR PART END'S HERE
            )
          );
        }
        $total_after_discount = $sub_total - $discount ;
  
        $statement = $conn-&gt;prepare(&quot;
          UPDATE tbl_medlab 
          SET sub_total = :sub_total, 
          discount = :discount, 
          total_after_discount = :total_after_discount 
          WHERE order_id = :order_id 
        &quot;);
        $statement-&gt;execute(
          array(
            ':sub_total'     =&gt;  $sub_total,
            ':discount'         =&gt;  $discount,
            ':total_after_discount'      =&gt;  $total_after_discount,
            ':order_id'             =&gt;  $order_id
          )
        );
        header(&quot;location:md_sale.php&quot;);
    }
  </code></pre>
  <p>I am getting an error part on line 74:</p>
  <blockquote>
  <p>Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in C:\xampp\htdocs\SanRem MD LAB\md_sale.php:74 Stack trace: #0 C:\xampp\htdocs\SanRem MD LAB\md_sale.php(74): PDOStatement-&gt;execute(Array) #1 {main} thrown in <strong>C:\xampp\htdocs\SanRem MD LAB\md_sale.php</strong> on line <strong>74</strong></p>
  </blockquote>
  <p>I already exhausted all the possible fixes but it is always showing that error.</p>
  <p>I was expecting for it to save the data to the database after I click on Create Invoice but then this error show up.</p>