0
我是Node中的新手,嘗試開發一些初始應用程序。我目前通過Node將記錄插入到數據庫(MySQL)中。我的文章方法就像通過節點插入記錄到MySQL數據庫時出錯
router.post('/add',function(req,res){
connection.connect();
var firstName = req.body.FirstName;
var lastName = req.body.LastName;
students.push({
//id: studentList.length+1,
FirstName: firstName,
LastName: lastName
});
var post = {FirstName: firstName, LastName: lastName};
connection.query('INSERT INTO tblstudent VALUES ? ', post,function(err,result){
if (err) {
res.send("There was a problem adding the information to the database.");
}
});
res.redirect('/');
connection.end();
});
其中Id是另一列,但自動遞增,所以我試圖插入記錄。我有以下錯誤。
請看看這個: http://stackoverflow.com/questions/7042340/node-js-error-cant-set-headers-after-they-are-sent – Dhruv