1

I set up all of my database information in javascript and It doesn't want to seem to connect. If it is connecting it doesn't update any data.

Here is my Query and Connection Code: Full Code: https://pastebin.com/PBMW6UM8

Query Code:

  var sql = "UPDATE tf2 SET credits = ? WHERE steamid = " + mysql.escape(id)
  con.query(sql, [totalcash], function (err, result) {
    if (err) throw err;
  });

Or look for //Query Code in Pastebin.

Extra Variables

<script>totalcash='<?php echo $credits; ?>'</script>
<script>id='<?php $steamprofile['steamid']; ?>'</script>
3
  • By default, mysql expects a port of 3306. Your code doesnt specify a port. Are you sure your db is on 3306? Commented Oct 16, 2017 at 18:10
  • Possible duplicate of Need assistance with accessing mysql database using node.js Commented Oct 16, 2017 at 18:15
  • My Mysql port is 3306 and i also defined the port as 3306 but this didn't fix it. Commented Oct 16, 2017 at 18:25

1 Answer 1

1

Connect to MySQL via the console and set a password for root user by running SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('yourDesieredPassword');

Then retry connecting Node using the code you already have, just with the updated password.

var con = mysql.createConnection({

  host: "localhost",

  user: "root",

  password: "yourDesiredPassword",

  database: "tf2"

});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.