'i am having a insertion issue in mysql using nodejs
Error: ER_BAD_NULL_ERROR: Column 'username' cannot be null
code: 'ER_BAD_NULL_ERROR',
errno: 1048,
sqlMessage: "Column 'username' cannot be null",
sqlState: '23000',
index: 0,
sql: 'insert into loginuser (username, email, password) values (NULL,NULL,NULL)'
this is my sevices code i cannot insert my data in the database kindly look into it and help in resolving the issue
module.exports = {
create: (data, callback) => {
pool.query(
"insert into loginuser (username, email, password) values (?,?,?)",
[
data.username,
data.email,
data.password
],
(error, results, fieds) => {
if(error){
return callback(error)
}
return callback(null, results)
}
);
}
Solution 1:[1]
Please check in phpMyadmin in your table STRUCTURE and allow NULL value for specific column in which you want to enter null if no value is passed.
https://i.stack.imgur.com/5X67a.png Check this Image.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Karan soni |
