MySQL Forums
Forum List  »  Connector/Node.js

Posted by: Raymond Jender
Date: June 26, 2020 12:52PM

So. I am using node v14.4.0, v0.9.19, mysql 8.0.20

Basically I am sending data from the client to the server. The data gets to the server just fine. I have a db called bcast with a table called room and column called roomid.

Note that the value of "+data+" is what I am trying to store at roomid and it's value is correct. Here is the snippet of code.

socket.on('data', (data) => {
console.log('roomid is = ', data);

var sql = "insert into room (roomid) values ("+data+");"
con.query(sql, function (err, result) {
if (err) throw err;
console.log("1 record inserted");

The sql query is failing with this error:

roomid is = exk9wwie1or

throw err; // Rethrow non-MySQL errors

Error: ER_BAD_FIELD_ERROR: Unknown column 'exk9wwie1or' in 'field list'
at Query.Sequence._packetToError (/root/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Query.ErrorPacket (/root/node_modules/mysql/lib/protocol/sequences/Query.js:79:18)
at Protocol._parsePacket (/root/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/root/node_modules/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (/root/node_modules/mysql/lib/protocol/Parser.js:43:10)
at Protocol.write (/root/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket.<anonymous> (/root/node_modules/mysql/lib/Connection.js:88:28)
at Socket.<anonymous> (/root/node_modules/mysql/lib/Connection.js:526:10)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:302:12)
at Protocol._enqueue (/root/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Connection.query (/root/node_modules/mysql/lib/Connection.js:198:25)
at Socket.<anonymous> (/root/RTCMultiConnection/server.js:306:7)
at Socket.emit (events.js:315:20)
at /root/RTCMultiConnection/node_modules/
at processTicksAndRejections (internal/process/task_queues.js:79:11) {
errno: 1054,
sqlMessage: "Unknown column 'exk9wwie1or' in 'field list'",
sqlState: '42S22',
index: 0,
sql: 'insert into room (roomid) values (exk9wwie1or);'

Why is it saying that exk9wwie1or is a column when it should be the contents of a column?

Options: ReplyQuote

Written By
June 26, 2020 12:52PM
June 30, 2020 11:31AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.