# Error: ER\_PARSE\_ERROR

**URL:** <https://discourse.nodered.org/t/error-er-parse-error/3771>\
**Category:** General\
**Created:** [8 October 2018 04:16 UTC](https://discourse.nodered.org/t/error-er-parse-error/3771 "2018-10-08T04:16:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tramanah](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tramanah/32/9122_2.png) [@tramanah](https://discourse.nodered.org/u/tramanah)\
**Post date:** [8 October 2018 04:16 UTC](https://discourse.nodered.org/t/error-er-parse-error/3771/1 "2018-10-08T04:16:03Z")

</div>

Good day, Below is json data coming from MQTT. I am trying to insert in mariadb.  
"{"DeviceId":4,"Line":1,"outPin":"GPIO 7","count":50,"Time":"2018-10-08 12:04:48"}"

I did create function block with the following script.

```
var obj = msg.payload;
var json = JSON.parse(obj);

msg.topic ="INSERT INTO mytable1 (DeviceId,outPin,count,Time) VALUES (?,?,?,?,?)";
msg.payload = [json.DeviceId, json.outPin, json.count, json.Time];

```

return msg;

Error msg : "Error: ER\_PARSE\_ERROR: 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 '?)' at line 1"

msg.payload output is  
array[4]

0: 4

1: "GPIO 7"

2: 50

3: "2018-10-08 12:13:06"

CREATE TABLE `mytable1` (  
`ID` INT(11) NOT NULL AUTO\_INCREMENT,  
`DeviceId` INT(5) NULL DEFAULT NULL,  
`Line` INT(5) NULL DEFAULT NULL,  
`outPIN` VARCHAR(10) NULL DEFAULT NULL COMMENT 'GPIO',  
`count` INT(5) NULL DEFAULT NULL,  
`Time` TIMESTAMP NOT NULL DEFAULT '',  
PRIMARY KEY (`ID`)  
)  
COLLATE='latin1\_swedish\_ci'  
ENGINE=InnoDB  
AUTO\_INCREMENT=25  
;

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 October 2018 07:45 UTC](https://discourse.nodered.org/t/error-er-parse-error/3771/2 "2018-10-08T07:45:46Z")

</div>

> [@tramanah](#):
>
> msg.topic ="INSERT INTO mytable1 (DeviceId,outPin,count,Time) VALUES (?,?,?,?,?)";

You have too many question marks.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [8 October 2018 07:46 UTC](https://discourse.nodered.org/t/error-er-parse-error/3771/3 "2018-10-08T07:46:53Z")

</div>

In your insert you name 4 columns but have 5 ‘?’

---

<div class="post-metadata">

**Author:** ![tramanah](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tramanah/32/9122_2.png) [@tramanah](https://discourse.nodered.org/u/tramanah)\
**Post date:** [8 October 2018 08:22 UTC](https://discourse.nodered.org/t/error-er-parse-error/3771/4 "2018-10-08T08:22:10Z")

</div>

Cheers. this drives me crazy.
