title: Javascript Function Not Returning Data - Node-MySQL
body: <p>Using NodeJS, Express, Socket.io &amp; node-mysql on a server at the moment.  Currently having a problem with one of the functions on the server not returning any data at all.  I'm at my ends wit trying to figure this out.</p>
  
  <p>Function Code;</p>
  
  <p>It is supposed to return "c", but is not working.  The console.log is actually showing the ID and username.</p>
  
  <pre><code>function LOGIN_USER(a,b) {
      // a    = username
      // b    = password
      var c = [];
      connection.query("SELECT ID FROM GAME_PLAYER WHERE USR = '" + a + "' AND PWD = '" + b + "'", function(err,rows,field) {
          if (err) throw err;
  
              for (var i in rows) {
                  c.ID = rows[i].ID;
                  c.USR = a;
              }
              console.log(c.ID + " " + c.USR);
              return c;
      });
  
  }
  </code></pre>
  
  <p>Other code.</p>
  
  <pre><code>socket.on('login user', function(data) {
          var c;
  
          c = LOGIN_USER(data.username,data.password);
          console.log(c.ID,c.USR);
      });
  </code></pre>
  
  <p>After this console.log is where my nodeJS server crashes.  Saying it can't display undefined etc.. etc.
  Can't for the life of me figure this out, any help is most appreciated!! :)</p>