1 (edited by wenchester21 2018-08-07 12:53:50)

Topic: (SOLVED) syntax ERROR

Hello, I am adapting your Login form with password change to a database in Mysql, (10.1.34-MariaDB), and cause several problems in the syntax of the query. Example

Before:

SQLExecute ('INSERT INTO users (login, password, read, write, remove, search, administrator) VALUES ("admin", "admin", 1, 1, 1, 1, 1);');

After. (works):

SQLExecute ('INSERT INTO users (login, `password`,` read`, `write`,` remove`, search, administrator) VALUES ("admin", "admin", 1, 1, 1, 1, 1); ');

In this I have problems:

s: = VarToStr (SQLExecute ('SELECT count (id) FROM users WHERE (login =' '' + frmLogin.edUser.Text + '' ') AND (password =' '' + frmLogin.edPassword.Text + '' ' ); '));

What would be the correct one for this problem?

Re: (SOLVED) syntax ERROR

Why do you end your lines with a double semi column?

 frmLogin.edPassword.Text + '' ' ); '));

Re: (SOLVED) syntax ERROR

Hello everyone, the problem is in the spaces between the quotes and some texts that seem to recognize them as reserved.

Examples:

// SQL query for check user and password
s := VarToStr( SQLExecute('SELECT count(id) FROM users WHERE (login = ''' + sUser + ''') AND (password = ' + frmChangePassword.edPassword.sqlValue + ');') );

Now it would be like that:

// SQL query for check user and password
s := VarToStr( SQLExecute('SELECT count(id) FROM users WHERE (login ='''+frmLogin.edUser.Text+''') AND (password ='''+frmLogin.edPassword.Text+''');') );

In the case of texts that seem to recognize them as reserved, it would be like this:

SQLExecute('INSERT INTO users(login, `password`, `read`, `write`, `remove`, search, administrator) VALUES ("admin", "admin", 1, 1, 1, 1, 1);');