1

I am simply trying to have this one button implement a function that simply shows the users scores for the game overall. This data is updated in an Access DB each time the user plays the game. I don't know if this is an issue with my SQL queries or with my JavaScript coding. I simply need a popup window to display this information when the user clicks this button. Code is as follows:(Just a portion of the code that's supposed to display the popup window, nothing more.)

<button onclick="showscores()" style=" top: 155px; left: 160px; position: absolute;"> Show scores

var user = "FOO";

var myDB = new ACCESSdb("C:\\Users\\FOO\\Users.mdb", {showErrors:true});

function showscores(){
    // select and retrieve the user info data , containing the score data 
    window.alert(myDB.query("SELECT * FROM userInfo WHERE UserName = 'username'));
}

2 Answers 2

1

You have a syntax error in your query - a missing closing double quote. It should be:

window.alert(myDB.query("SELECT * FROM userInfo WHERE UserName = 'username'"));
Sign up to request clarification or add additional context in comments.

Comments

0

myDB should be declared within the function unless declared globally, its not clear in your example if that is the case.

function showscores(){
    var myDB = new ACCESSdb("C:\\Users\\FOO\\Users.mdb", {showErrors:true});
    // select and retrieve the user info data , containing the score data 
    window.alert(myDB.query("SELECT * FROM userInfo WHERE UserName = 'username'"));
}

3 Comments

Yes, I did declare it globally. Sorry for the ambiguity. Now that I fixed the double quote syntax error, I'm getting back a false value from my database.
Cool, I suggest opening a new question for that as it may be one of many things, file path, table name, column name etc
Okay , will make a new question then.

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.