D1_ERROR: Wrong number of parameter bindings for SQL query.

Hello, can someone tell me what I'm doing wrong that I get this error? If you need more Infos please ask.
export default {
async fetch(request, env) {
const { DATABASE } = env;
let input = await request.formData();

let username = input.get('username');
let email = input.get('email');
let message = input.get('message');

console.log(`Username: ${username}`);
console.log(`Email: ${email}`);
console.log(`Message: ${message}`);

if (!username || !email || !message) {
console.log('Errors in data transfer try again');
return new Response('Errors in data transfer try again', {
headers: {
'Content-Type': 'text/html;charset=utf-8',
},
});
}

let id = new Date().toISOString();
console.log(`ID: ${id}`);

const stmt = DATABASE.prepare("INSERT INTO submit (id, username, email, message) VALUES (?, ?, ?, ?)");
await stmt.run(id, username, email, message);

console.log('Message delivered');
return new Response('Message delivered', {
headers: {
'Content-Type': 'text/html;charset=utf-8',
},
});
}
};
export default {
async fetch(request, env) {
const { DATABASE } = env;
let input = await request.formData();

let username = input.get('username');
let email = input.get('email');
let message = input.get('message');

console.log(`Username: ${username}`);
console.log(`Email: ${email}`);
console.log(`Message: ${message}`);

if (!username || !email || !message) {
console.log('Errors in data transfer try again');
return new Response('Errors in data transfer try again', {
headers: {
'Content-Type': 'text/html;charset=utf-8',
},
});
}

let id = new Date().toISOString();
console.log(`ID: ${id}`);

const stmt = DATABASE.prepare("INSERT INTO submit (id, username, email, message) VALUES (?, ?, ?, ?)");
await stmt.run(id, username, email, message);

console.log('Message delivered');
return new Response('Message delivered', {
headers: {
'Content-Type': 'text/html;charset=utf-8',
},
});
}
};
3 Replies
Flinkpfote
FlinkpfoteOP8mo ago
No description
Flinkpfote
FlinkpfoteOP8mo ago
Thank you very much!
Want results from more Discord servers?
Add your server