Sign in to follow this  
Hanvod

MySQL connect() isnt working.

Recommended Posts

I am using the following code:

var SQL = require('mysql')
var c = SQL.createConnection({
  host: '*here was my ip*',
  user: '*here was my user*',
  password: '*here was my password*',
  database: '*here was my database*'
});
console.log("TESTTESTTEST");
c.connect(function(e) {
console.log(123);
if(e) {
	console.log("Error connecting to the database with error "+e);
}
else {
	console.log('Database connected!')
}
});
c.query("INSERT INTO Cars VALUES (5,5,5,5,123)")
c.query("SELECT * FROM Cars", (err, result) => {
	console.log(result);
});

and it doesnt work when I run it as a part of server package, but works well when I run it with Node.

rx52aLw.png

Please, help me.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.