Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8175723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:52:40+00:00 2026-06-06T22:52:40+00:00

I have been stuck on this for a while now and I cannot seem

  • 0

I have been stuck on this for a while now and I cannot seem to insert two variables into a table. I would think this code should work…

var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);

function submit() 
{
    var input = document.getElementById("save_name").value;
    var msg;
    var time_stamp = new Date();

    db.transaction(function (tx) 
    {
        tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id auto_increment, date_time varchar(128), log varchar(64))');
        tx.executeSql('INSERT INTO LOGS (log, date_time) VALUES (?, ?)', [input, time_stamp]); // <--Problem here!
        msg = '<p>Log message created and row inserted.</p>';
        document.querySelector('#status').innerHTML = msg;
    });
}

But it is not inserting my variables to my table.

Here is my printing function:

function display_fields() 
{
    db.transaction(function (tx) 
    {
        tx.executeSql('SELECT * FROM LOGS', [], function (tx, results) {
            var len = results.rows.length, i;
            msg = "<p>Found rows: " + len + "</p>";
            document.querySelector('#status').innerHTML += msg;
            for (i = 0; i < len; i++) 
            {
                msg = "<p><b>" + results.rows.item(i).log + " " + result.rows.item(i).date_time + "</b></p>";
                document.querySelector('#status').innerHTML += msg;
            }
        }, null);
    });
}

Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T22:52:42+00:00Added an answer on June 6, 2026 at 10:52 pm

    The only way I could get this to work was by cancatinating

    Here is what I did:

    tx.executeSql('INSERT INTO LOGS (log, date_time) VALUES ("' + input + '", "' + time_stamp + '")');
    

    I know this opens up to SQL injections but I couldn’t get it to work any other way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been stuck with this problem for a while now, and I just
I have been stuck on this problem for a while now. I want to
I've been stuck on this for 3 days now. I have two pages that
This is something I've been stuck on for a while now, and I have
I've been stuck on this problem for a while now and have tried my
I'm stuck in this problem for quite while now. I have two tables ItemMaster
I have been stuck on this for a while. i have tried and I
I have been stuck on this silly if statement, whatever i do, I cannot
so i have been stuck with this issue for 3 weeks now and i
I have now been stuck at this for some time so I though to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.