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>
asked Oct 16, 2017 at 18:03
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"
});
answered Oct 17, 2017 at 15:40
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.