我使用expressjs和node-mysql模塊。我得到這個錯誤,當我發佈到更新動作expressjs mysql更新錯誤
/Users/mac/node_modules/mysql/lib/mysql/client.js:106
cb(err);
^
TypeError: string is not a function
at String.CALL_NON_FUNCTION (native)
at Query.<anonymous> (/Users/mac/node_modules/mysql/lib/mysql/client.js:106:9)
at Query.emit (events.js:64:17)
at Query._handlePacket (/Users/mac/node_modules/mysql/lib/mysql/query.js:35:12)
at Client._handlePacket (/Users/mca/node_modules/mysql/lib/mysql/client.js:294:14)
at Parser.<anonymous> (/Users/mac/node_modules/mysql/lib/mysql/client.js:83:14)
at Parser.emit (events.js:64:17)
at /Users/mac/node_modules/mysql/lib/mysql/parser.js:75:14
at Parser.write (/Users/mac/node_modules/mysql/lib/mysql/parser.js:580:7)
at Socket.<anonymous> (/Users/mca/node_modules/mysql/lib/mysql/client.js:63:16)
我用這個動作:
app.post('/post/:id/edit', function(req, res){
var id = req.params.id;
var query = client.query(
'UPDATE '+POST,
'SET title = ?, text = ?',
[req.body.title, req.body.text ],
' WHERE id='+id
);
res.redirect('/');
});
有什麼不對?
哪裏定義了'cb'? – jcolebrand 2011-05-13 16:36:29