The code doesn't know you want to insert the values of Current and Voltage into the string - it just sees the text Current and Voltage.
One way to do it is to build the string up by joining together the different parts:
var Current = msg.payload.Current
var Voltage = msg.payload.Voltage
msg.topic = "INSERT INTO Data(`Current`, `Voltage`) VALUES ('"+Current+"', '"+Voltage+"')";
return msg;
Although I may have replied a bit too quickly as your screenshot of the messages shows you don't have msg.payload.Current and msg.payload.Voltage as your Function code assumes.
Instead you appear to have the two values arriving in different messages, with msg.topic identifying whether its Current or Voltage, and the corresponding value in msg.payload.
So you first need to get those two separate messages into one message so you can do a single insert with them both.
To do that, add a Join node, configured as follows:
At the moment it is hard to see how all of those screenshots relate to each other.
What does your flow look like? Where are the Debug nodes you are showing the output of in relation to the Function node and the MySQL node? Where have you put the Join node?
The Debug screenshot shows you have a message where msg.payload in now an object - but we can't see what that object looks like. Expand that out to confirm the payload contains a Current and Voltage property.
HI.
Right Sorry about the delay getting back. I have edited the Join mode to the below, so the first value is my Voltage and the second is my Current, and then it hits the Function it gives the error in the Insert INTO
Now while it is sending data it seems also send undefind data also, and it looks like it comes from the same Function Modual. Any reason why that would occur please
My mistake, It was sending data when received from the Modbus interface and I also had an inject on it alos, so it would send no data. All done now, Time to play with the PHP and hTML to make a nice datalogger. Thank again