title: node.js & mysql - How to get the last inserted ID?
body: <pre><code>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);
  });
  </code></pre>
  
  <p>The console told me:</p>
  
  <blockquote>
    <p>Cannot read property 'insertId' of null</p>
  </blockquote>
  
  <p>After I had searched for a solution I found this page:
  <a href="https://github.com/mysqljs/mysql#getting-the-id-of-an-inserted-row" rel="nofollow">https://github.com/mysqljs/mysql#getting-the-id-of-an-inserted-row</a></p>
  
  <p>According to this documentation, it must work.
  Where's my mistake?
  Thanks in advance.</p>