I've a form on my page where I want to be able to submit data into my database/table, but get the error. The amount of given values do match the given columns in the code, so now I don't know exactly where to look for the error.
- My table has 4 columns (the 'id' should auto-increment).
- The input gets logged in the console
- I run it on localhost
- I'm using nextjs
My code:
import { query } from "../../lib/db";
export default async function handler(req, res) {
// Get data submitted in request's body.
const body = req.body;
const streamer = req.body.streamer;
const clip = req.body.clip;
const category = req.body.category;
console.log('- - - - - - -');
console.log('body: ', body);
console.log('- - - - - - -');
console.log('streamer: ', streamer);
console.log('clip: ', clip);
console.log('category: ', category);
console.log('- - - - - - -');
if (req.method === "POST") {
try {
const insertSQL = await query({
query: "INSERT INTO submissions2023 (streamer, clip, category) VALUES (?)",
values: [streamer, clip, category]
});
res.status(200).json({ data: 'Success :' + streamer });
} catch (error) {
res.status(500).json({ data: error.message });
}
}
}
I changed the way of coding the query and values but this resulted in other errors.


I found my mistake and made following changes: