socket io not sending properly

I am trying to test if my sockets are sending properly from server to the client by using console.log to check if the data sent was correct. Nothing is ever outputted.

What I am currently doing on the server side:

connection.query(a_id, function(err, results, fields){
   if(err) throw err;

   var tutors = [];

   for(j in results){
      tutors.push(results[j]);
   }
   db.push({tutors: tutors});
  //console.log(JSON.stringify(db));

  io.on('connection', function(socket){
    socket.emit('new', "hello");
  }); 
});

Than on the client side I am doing

io.on('connection', function(socket){
  console.log("connected");
  socket.on('new', function(data){
    console.log(data);
  });
});

I am not sure why data is not being printed maybe I dont fully understand sockets? Any insight would be appreciated.

Init your connection outside of query. Here is example how to use io.on('connection')