I just made a simple HTML5 game for mobile webkit. I have made a simple function that inserts the record into the database:
Javascript:
db = openDatabase('highscores', '1.0', 'Whackem Highscores', 2 * 1024 * 1024);
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE scores (id unique, int,text)');
tx.executeSql('INSERT INTO foo (id, text) VALUES (?,?,?)',["",score,date1]);
});
It doesn’t seem to do anything!?
How can I fix this?
I also have to make a loop that prints out the highest scores, If you have any advice on something like that, it would also be very helpful.
You probably want something more like:
Note that you’ll have to explicitly DROP your original table.
Each
executeSqlcommand takes a success and a failure handler as arguments after the parameter list; adding those will help debug failed queries in the future, as they otherwise fail silently.