title: NodeJS and MySQL Getting 500 error after first query
body: <p>I have declared <code>mysql</code>, and my connection in <code>app.js</code> like so:</p>
  
  <pre><code>var mysql = require('mysql');
  var connection = mysql.createConnection({
      host: '192.168.1.75',
      user: 'dev',
      password: 'devaccount',
      database: 'PugIt'
  });
  
  app.set('connection', connection);
  </code></pre>
  
  <p>And in my <code>User.js</code> for registration I have:</p>
  
  <pre><code>router.route('/register/steam/finish')
      .get(function(req, res) {
          res.render('user/register_steam');
      })
      .post(function(req, res) {
          var connection = req.app.get('connection');
          connection.connect();
  
          // Look For Users
          connection.query("SELECT * FROM Users", function(err, rows, fields) {
              console.log('We Found Something!');
          });
  
          connection.end();
      });
  </code></pre>
  
  <p>When the page first loads and I hit register, it works fine, but if I hit the button a second time I get a <code>500</code> error on my server.</p>
  
  <p>But if I manually declare <code>var connection</code> inside each <code>route</code> file, this does not happen.</p>
  
  <p>How come I cannot use <code>req.app.get</code> with MySQL, I used this method when I used to use <code>MongoDB</code> which worked great that way I had one main config in app.js I could alter to change in all route files if I needed. Not sure why I'm getting a <code>500</code> error on second <code>POST</code></p>