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>
-
By default, mysql expects a port of 3306. Your code doesnt specify a port. Are you sure your db is on 3306?Tom O.– Tom O.2017年10月16日 18:10:04 +00:00Commented Oct 16, 2017 at 18:10
-
Possible duplicate of Need assistance with accessing mysql database using node.jsTom O.– Tom O.2017年10月16日 18:15:54 +00:00Commented 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.Samuel Stubbings– Samuel Stubbings2017年10月16日 18:25:33 +00:00Commented Oct 16, 2017 at 18:25
1 Answer 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
Tom O.
5,9813 gold badges24 silver badges36 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
default