0

I am trying to insert values into a database (MariaDB) using SQL injection.

var insertValues = {'username': username, 'firstname': firstname, 'lastname': lastname, 'email': email,
                        'password':password, 'profileType': profileType,'userType': userType, 'gcmId': gcmId,
                        'deviceName': deviceName, 'osType': osType, 'osVersion': osVersion,'isBlocked':isBlocked,
                        'isActive':isActive, 'ofActive':ofActive};

The query format I used is:

    function registerUser(insertValues,callback)
{
    model.client.query('insert into users set ?',insertValues,function(err) {
      if(!err)
            callback({"success":'1'});
        else
            console.log(err);
            callback({"success":'0'});
    });
}
module.exports.registerUser=registerUser;

But this gives a syntax error:

Maria Db Connected at : 128.199.242.240
{ [Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NULL' at line 1] code: 1064 }

1
  • Show us the INSERT after the ? has been replaced. Commented Jun 30, 2016 at 22:00

1 Answer 1

1

Two mistakes:

model.client.query("insert into users set ?",data;
                      column missing -----^
                  closing parantheses missing ---^

Should be something like:

model.client.query("insert into users set your_column = ?", data);
Sign up to request clarification or add additional context in comments.

Comments

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.