# Error was reported when the data is stored in the Mysql

**URL:** <https://discourse.nodered.org/t/error-was-reported-when-the-data-is-stored-in-the-mysql/18669>\
**Category:** General\
**Created:** [1 December 2019 19:46 UTC](https://discourse.nodered.org/t/error-was-reported-when-the-data-is-stored-in-the-mysql/18669 "2019-12-01T19:46:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![molly](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@molly](https://discourse.nodered.org/u/molly)\
**Post date:** [1 December 2019 19:46 UTC](https://discourse.nodered.org/t/error-was-reported-when-the-data-is-stored-in-the-mysql/18669/1 "2019-12-01T19:46:03Z")

</div>

Hi everyone,  
I have been trying to store the humidity and light values to a Mysql database, and displayed as a table 'mqtt', the flow is like this:

 ![1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/c461942fc53af9985e1ff57120e47f4b8e5e13e1.jpeg)  
The sensed value is shown in msg.payload.payload\_fields which are humidity and light, and the code of function node 'Create query in topic' is

```auto
var newmsg=new Date().toString();
msg.topic="INSERT INTO mqtt VALUES ('"+ new Date().toString() +"','"+ msg.payload.payload_fields.humidity +"','"+ msg.payload.payload_fields.light +"')";
return msg;

```

But there import an error:  
 ![2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/a0575c046f8ddfba881e36cfadb018e800f49192.jpeg)  
I am confused of which part is wrong, maybe the code of function node. Thanks for your help!!!

---

<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:** [1 December 2019 21:08 UTC](https://discourse.nodered.org/t/error-was-reported-when-the-data-is-stored-in-the-mysql/18669/2 "2019-12-01T21:08:28Z")

</div>

What does the table in mysql look like - i.e how many rows are there?

If you have more than 3 columns defined in the table that might be the problem, you would need to specify the name of each column like this

```auto
msg.topic = "INSERT INTO ws_sensor_data(location, sensor, value, epoch)" + 
        "VALUES('"+location+"', 'wifi_strength', "+wifi_strength+","+epoch+")";

```

using your own column names and variables of course.
