SQLSTATE[42000]: Syntax error or access violation: 1064 ... near 'INSERT INTO `ps_kfasupply_warehouse_receipt_detail` (`id_ware...' at line 6

31 views Asked by At

We have a module which is working fine PrestaShop 1.6.1.23 - PHP 7.1 But it is throwing this error on PrestaShop 1.7.8.9 and 8.1.2 (PHP 7.4 & 8.1).

This is the error in PS1.7:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO `ps_kfasupply_warehouse_receipt_detail` (`id_warehou' at line 6

INSERT INTO `ps_kfasupply_warehouse_receipt_detail`
(`id_warehouse_receipt`, `row_number`, `name`, `quantity`, `sales_return_quantity`, `barcode`, `supplier_reference`, `package_type`, `quantity_per_package`, `description`)
VALUES(1, '1', 'test1', 10, 0, '', '', '', 0, '');

INSERT INTO `ps_kfasupply_warehouse_receipt_detail`
(`id_warehouse_receipt`, `row_number`, `name`, `quantity`, `sales_return_quantity`, `barcode`, `supplier_reference`, `package_type`, `quantity_per_package`, `description`)
VALUES(1, '2', 'test2', 20, 0, '', '', '', 0, '');

This is the error in PS8.1:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INSERT INTO `ps_kfasupply_warehouse_receipt_detail` (`id_ware...' at line 6

(The query is the same: 2 INSERTs).


More information:

This is a form for a warehouse receipt that has some fields like Supplier and Brands and Invoice info's and also has a list of items. The form submits when there is no item or even when there is only 1 item. But when I add 2 or more items, I get these errors.

The way it is handled is in a foreach the queries for all the warehouse items (Insert) are created and added into a string. Then the string is executed at the end.

When I manually test this whole query in phpMyAdmin, it works.


How can I solve this?

0

There are 0 answers