Connecting to Database

Hello there,

I have been using the Auth0 for its Single Sign-On feature. However, I’ve been recently assigned to connect the web application to a database. I’ve followed the article which provides instructions on how to do this but I keep getting an error as the application won’t connect to the database through Auth0 and I’m struggling to break down the problem. By the way, I’m using localhost at the moment and my application is written in PHP.
I would really appreciate if you could offer some support on how to solve this issue or recommend any contact I can get in touch with for assistance.

Thank you
Mo

Please get us the error message along with the specific code so we can review, making sure to remove any sensitive information like passwords, keys, etc.

function login(email, password, callback) {

var connection = mysql({
host: ‘localhost’,
user: ‘’,
password: ‘’,
database: ‘’
});

connection.connect();

var query = "SELECT id, nickname, email, password " +
“FROM users WHERE email = ?”;

connection.query(query, [email], function (err, results) {
if (err) return callback(err);
if (results.length === 0) return callback(new WrongUsernameOrPasswordError(email));
var user = results[0];

bcrypt.compare(password, user.password, function (err, isValid) {
  if (err) {
    callback(err);
  } else if (!isValid) {
    callback(new WrongUsernameOrPasswordError(email));
  } else {
    callback(null, {
      id: user.id.toString(),
      nickname: user.nickname,
      email: user.email
    });
  }
});

});
}

That’s the generated code from ‘Connections > Database > Custom Database’ when setting up the database connection. Unlike in the code above, I have set values for user, password and database. When I try to save the settings, I get an error saying “Line 16: ‘WrongUsernameOrPasswordError’ is not defined” and “Line 23: ‘WrongUsernameOrPasswordError’ is not defined”. Moreover, if I try to test the connect by logging in with a user in the database, I get another error saying “connect ECONNREFUSED 127.0.0.1:3306”.

Thanks for the reply. Sorry about the long message, I am really desperate to solve this issue as my final year university project depends on it. Please let me know if you would like to see screenshots.

Hey there!

Terribly sorry for such delay in response! We’re doing our best in providing you with best developer support experience out there but sometimes our bandwidth is not enough for all the questions we get.

Hope your university project went well! Let mem know of you still have any issues