Skip to content
Advertisement

Unknown column ‘narozeni’ in ‘field list’ [closed]

Hello Im making database record in my discord.js bot. But im steel getting this error:

/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`)'
}

Code:

             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");
               });
             });

Db:

Image here!

I want to make record in database. I actually tried to give on values `. But still happens same error

Advertisement

Answer

Try using single or double quotes in the raw sql query. For example:

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

Backticks are not used in this way in SQL

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement