Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>thanks, console.log(JSON.stringify(myVariable)); worked for my case. Variable has shown as { coloumn_that_result_lays: "result"}. Of course we can overcome it with javascript-substring but is there a function which gives "result" directly.</p> <pre><code> // Require HTTP module (to start server) and Socket.IO var io = require('socket.io'), http = require('http'); io = require('socket.io'); // Start the server at port 8080 var server = http.createServer(function(req, res){ // Send HTML headers and message res.writeHead(200,{ 'Content-Type': 'text/html' }); res.end('&lt;h1&gt;Hello Socket Lover!&lt;/h1&gt;'); }); server.listen(8080); // Create a Socket.IO instance, passing it our server var socket = io.listen(server); // Add a connect listener socket.on('connection', function (client){ //mysql var mysql = require('db-mysql'); new mysql.Database({ hostname: 'localhost', user: 'root', password: '123123', database: 'node' }).connect(function(error) { if (error) { return console.log('CONNECTION error: ' + error); } this.query('SELECT data FROM exam where id=2 '). execute(function(error,result) { if (error) { console.log('ERROR: ' + error); return; } client.json.send(JSON.stringify(result)); }); }); // Create periodical which ends a message to the client every 5 seconds var interval = setInterval(function() { client.send('This is a message from the server! ' ); },1000); // Success! Now listen to messages to be received client.on('message',function(event){ console.log('Received message from client!',event); }); client.on('disconnect',function(){ clearInterval(interval); console.log('Server has disconnected'); }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload