Advertisement
Guest User

Untitled

a guest
Sep 5th, 2016
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. var sql = require('mysql');
  2. var db_config = {
  3. host: 'localhost',
  4. user: 'root',
  5. password: 'uttkarsh',
  6. database: 'partners_invoice'
  7. }
  8. var connection = sql.createConnection(db_config);
  9. // connection.connect(...) is just a way to test whether database connection
  10. // is working or not. I'm not sure about it's return value.
  11. // You need to use that connection object for queries.
  12. //
  13. //var con = connection.connect(function(err){
  14. // if(err) throw err;
  15. //})
  16.  
  17. // User_ID is not defined :
  18. var User_ID=1234;
  19. connection.query('SELECT * FROM user_data WHERE User_ID = ?',[User_ID], function(error, result){
  20. if(error) throw error;
  21. console.log(result);
  22. });
  23. connection.end();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement