db.query("INSERT INTO `chat_entries`(`author`, `authorRank`, `receiver`, `timestamp`, `message`) VALUES (" + db.escape(GetUsername(connection)) + ", " + GetUserData(GetUsername(connection), "rank") + ", '-', " + Math.round(new Date().getTime() / 1000) + ", '" + db.escape(messageData.message) + "')", function(result, rows){
console.log(result.insertId);
});
The console told me:
Cannot read property 'insertId' of null
After I had searched for a solution I found this page: https://github.com/mysqljs/mysql#getting-the-id-of-an-inserted-row
According to this documentation, it must work. Where's my mistake? Thanks in advance.
Your callback params are wrong. Try this: