%q latest sqlite escaping specifier.
#1

I am mind-fucked right now. I don't even know why it works on SELECT but it doesn't work using INSERT or I've done something wrong or the specifier wasn't explained properly and confused a lot of people.

Detecting if register or not
pawn Код:
new rows;
rows =  db_parse(dataBase, ""TABLE_ACCOUNTS"", ""FIELD_USERNAME" = %q", playerData[playerid][playerUsername]);
pawn Код:
[12:43:15] [db_log_queries]: SELECT * FROM `Accounts` WHERE Username = Wells
[12:43:15] [Warning] db_query: Query failed: no such column: Wells - (no colums, so proceed to register menu.)
Register
pawn Код:
new dbQuery[210];
WP_Hash(playerData[playerid][playerPassword], 129, inputtext);
format(dbQuery, sizeof(dbQuery), "INSERT INTO "TABLE_ACCOUNTS" ("FIELD_USERNAME", "FIELD_PASSWORD") VALUES (%q, %q)", playerData[playerid][playerUsername], playerData[playerid][playerPassword]);
db_free_result(db_query(dataBase, dbQuery));
pawn Код:
[12:43:20] [db_log_queries]: INSERT INTO Accounts (Username, Password) VALUES (, )
[12:43:20] [Warning] db_query: Query failed: near ",": syntax error
[12:43:20] [Error] db_free_result(): invalid result handle 0
[12:43:20] INSERT INTO Accounts (Username, Password) VALUES (, )
Am I doing something wrong? or the new updates aren't documented properly.
Reply
#2

%q needs to be '%q' in the first example.

pawn Код:
new rows;
rows =  db_parse(dataBase, ""TABLE_ACCOUNTS"", ""FIELD_USERNAME" = '%q'", playerData[playerid][playerUsername]);
Reply
#3

Quote:
Originally Posted by Emmet_
Посмотреть сообщение
%q needs to be '%q' in the first example.

pawn Код:
new rows;
rows =  db_parse(dataBase, ""TABLE_ACCOUNTS"", ""FIELD_USERNAME" = '%q'", playerData[playerid][playerUsername]);
I've done that, without 'q' and with 'q'. same problem.

pawn Код:
[13:03:29] [db_log_queries]: SELECT * FROM `Accounts` WHERE Username = '[AM]pds'
[13:03:31] [db_log_queries]: INSERT INTO Accounts (Username, Password) VALUES ('', '')
[13:03:35] [db_log_queries]: UPDATE Accounts SET Admin = 67, Kills = 67, Deaths = 67 WHERE Username =
[13:03:35] [Warning] db_query: Query failed: near " ": syntax error
Reply
#4

The username in the update query shown above is not properly formatted.
Reply
#5

Quote:
Originally Posted by Emmet_
Посмотреть сообщение
The username in the update query shown above is not properly formatted.
What do you mean?

Its cool if its formated like that, worked perfectly before and it is still working but the specifier doesn't seem to work properly on any format.
Reply
#6

The update query looks like this.

Код:
[13:03:35] [db_log_queries]: UPDATE Accounts SET Admin = 67, Kills = 67, Deaths = 67 WHERE Username =
What does it look like in your script?
Reply
#7

I'll read some stuff again, I just came back so I lost some knowledge.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)