title: Node-Mysql error in saving data
body: <p>I am studying nodejs with mysql and I am following this example:
  <a href="https://codeforgeek.com/2015/03/real-time-app-socket-io/" rel="nofollow">https://codeforgeek.com/2015/03/real-time-app-socket-io/</a></p>
  
  <p>But when I run the code and try to add a new data I got these errors:</p>
  
  <pre><code>C:\wamp\www\Node_JS\mysql&gt;node server.js
  Listening on 3000
  A user is connected!
  A user is connected!
  C:\wamp\www\Node_JS\mysql\node_modules\mysql\lib\protocol\Parser.js:82
          throw err;
                ^
  TypeError: Cannot read property 'release' of undefined
      at C:\wamp\www\Node_JS\mysql\server.js:37:14
      at Handshake.onConnect (C:\wamp\www\Node_JS\mysql\node_modules\mysql\lib\Pool.js:54:9)
      at Handshake.Sequence.end (C:\wamp\www\Node_JS\mysql\node_modules\mysql\lib\protocol\sequences\Sequence.js:96:24)
      at Handshake.ErrorPacket (C:\wamp\www\Node_JS\mysql\node_modules\mysql\lib\protocol\sequences\Handshake.js:103:8)
      at Protocol._parsePacket (C:\wamp\www\Node_JS\mysql\node_modules\mysql\lib\protocol\Protocol.js:274:23)
      at Parser.write (C:\wamp\www\Node_JS\mysql\node_modules\mysql\lib\protocol\Parser.js:77:12)
      at Protocol.write (C:\wamp\www\Node_JS\mysql\node_modules\mysql\lib\protocol\Protocol.js:39:16)
      at Socket.&lt;anonymous&gt; (C:\wamp\www\Node_JS\mysql\node_modules\mysql\lib\Connection.js:96:28)
      at Socket.emit (events.js:107:17)
      at readableAddChunk (_stream_readable.js:163:16)
  </code></pre>
  
  <p>Here's my code in the server.js</p>
  
  <pre><code>var app     = require('express')();
  var mysql   = require('mysql');
  var http    = require('http').Server(app);
  var io      = require('socket.io')(http);
  
  /** mysql pool connection **/
  var pool = mysql.createPool({
      connectionLimit :   100,
      host            :   'localhost',
      user            :   'root',
      password        :   '',
      database        :   'fbstatus',
      debug           :   false
  });
  
  app.get('/', function(req, res){
      res.sendFile(__dirname + '/index.html');
  });
  
  /** this will run automatically if server received a connection **/
  io.on('connection', function(socket){
      console.log('A user is connected!');
      socket.on('status added', function(status){
          add_status(status, function(res){
              if(res) {
                  io.emit('refresh feed', status);
              } else {
                  io.emit('error');
              }
          });
      });
  });
  
  var add_status = function(status, callback) {
      pool.getConnection(function(err, connection){
          if(err) {
              connection.release();
              callback(false);
              return;
          }
          connection.query("INSERT INTO fb_status VALUES('" + status + "')", function(err, rows){
              connection.release();
              if(!err) {
                  callback(true);
              }
          });
          connection.on('error', function(err){
              callback(false);
              return;
          });
      });
  }
  
  http.listen(3000, function(){
      console.log("Listening on 3000");
  });
  </code></pre>
  
  <p>I dont know whats the problem about my code. Can you help me?</p>