javascript “字段列表”中的列“narozeni”未知

trnvg8h3  于 2022-11-20  发布在  Java
关注(0)|答案(1)|浏览(117)

你好我正在我的discord.js机器人数据库记录。但我钢得到这个错误:

/home/container/node_modules/mysql/lib/protocol/Parser.js:437
      throw err; // Rethrow non-MySQL errors
      ^
Error: ER_BAD_FIELD_ERROR: Unknown column 'narozeni' in 'field list'
    at Query.Sequence._packetToError (/home/container/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
    at Query.ErrorPacket (/home/container/node_modules/mysql/lib/protocol/sequences/Query.js:79:18)
    at Protocol._parsePacket (/home/container/node_modules/mysql/lib/protocol/Protocol.js:291:23)
    at Parser._parsePacket (/home/container/node_modules/mysql/lib/protocol/Parser.js:433:10)
    at Parser.write (/home/container/node_modules/mysql/lib/protocol/Parser.js:43:10)
    at Protocol.write (/home/container/node_modules/mysql/lib/protocol/Protocol.js:38:16)
    at Socket.<anonymous> (/home/container/node_modules/mysql/lib/Connection.js:88:28)
    at Socket.<anonymous> (/home/container/node_modules/mysql/lib/Connection.js:526:10)
    at Socket.emit (node:events:527:28)
    at addChunk (node:internal/streams/readable:324:12)
    --------------------
    at Protocol._enqueue (/home/container/node_modules/mysql/lib/protocol/Protocol.js:144:48)
    at Connection.query (/home/container/node_modules/mysql/lib/Connection.js:198:25)
    at Handshake.<anonymous> (/home/container/commands/postava.js:132:20)
    at Handshake.<anonymous> (/home/container/node_modules/mysql/lib/Connection.js:526:10)
    at Handshake._callback (/home/container/node_modules/mysql/lib/Connection.js:488:16)
    at Handshake.Sequence.end (/home/container/node_modules/mysql/lib/protocol/sequences/Sequence.js:83:24)
    at Handshake.Sequence.OkPacket (/home/container/node_modules/mysql/lib/protocol/sequences/Sequence.js:92:8)
    at Protocol._parsePacket (/home/container/node_modules/mysql/lib/protocol/Protocol.js:291:23)
    at Parser._parsePacket (/home/container/node_modules/mysql/lib/protocol/Parser.js:433:10)
    at Parser.write (/home/container/node_modules/mysql/lib/protocol/Parser.js:43:10) {
  code: 'ER_BAD_FIELD_ERROR',
  errno: 1054,
  sqlMessage: "Unknown column 'narozeni' in 'field list'",
  sqlState: '42S22',
  index: 0,
  sql: 'INSERT INTO charaktery (jmeno, prijmeni, datumnarozeni, vek, cisloprukazu, discord, roblox) VALUES (`jmeno`, `prijmeni`, `narozeni`, `vek`, `randomp`, `discord.id`, `roblox`)'
}

代码:

con.connect(function(err) {
               if (err) throw err;
               console.log("Connected!");
               var sql = "INSERT INTO charaktery (jmeno, prijmeni, datumnarozeni, vek, cisloprukazu, discord, roblox) VALUES (`jmeno`, `prijmeni`, `narozeni`, `vek`, `randomp`, `discord.id`, `roblox`)";
               con.query(sql, function (err, result) {
                 if (err) throw err;
                 console.log("1 record inserted");
               });
             });

数据库:

Image here!
我想在数据库中做一个记录。我实际上试着给予值。但是仍然发生同样的错误。

67up9zun

67up9zun1#

尝试在原始sql查询中使用单引号或双引号。例如:

var sql = "INSERT INTO charaktery (jmeno, prijmeni, datumnarozeni, vek, cisloprukazu, discord, roblox) VALUES ('jmeno', 'prijmeni', 'narozeni', 'vek', 'randomp', 'discord.id', 'roblox')";

在SQL中不以这种方式使用反斜线号

相关问题