2021-03-21, 05:42 PM
I am trying to create an SQLite database, I only have three variables to keep it simple.
The problem is that the password is not saved unless I pass <inputtext> directly to the query.
Variables:
Code working:
Code isn't working:
The password field on the database is empty, and other values are ok. No error has given from the compiler.
The problem is that the password is not saved unless I pass <inputtext> directly to the query.
Variables:
Code:
enum USER_DATA {
? ? USER_ID,
? ? USER_NICKNAME[MAX_PLAYER_NAME],
? ? USER_PASSWORD[20]
};
new gUserData[MAX_PLAYERS][USER_DATA];
Code working:
Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
? ? switch (dialogid) {
? ? ? ? case DIALOG_REGISTRATION: {
? ? ? ? ? ? if (!response) return Kick(playerid);
? ? ? ? ? ? if (!(3 <= strlen(inputtext) <= 20)) {
? ? ? ? ? ? ? ? SendClientMessage(playerid, -1, "Tu contrase?a debe tener entre 3 y 20 car?cteres");
? ? ? ? ? ? ? ? ShowPlayerDialog(playerid, DIALOG_REGISTRATION, DIALOG_STYLE_PASSWORD, "Register", "Type in a password below to register an account.", "Register", "Leave" );
? ? ? ? ? ? ? ? return 1;
? ? ? ? ? ? }
? ? ? ? ? ? new query[208], DBResult: result;
? ? ? ? ? ?
? ? ? ? ? ? format(query, sizeof query, "INSERT INTO users (nickname, password) VALUES ('%q', '%s')", gUserData[playerid][USER_NICKNAME], inputtext);
? ? ? ? ? ? db_query(db_handle, query);
? ? ? ? ? ? SendClientMessage(playerid, 0x00FF00FF, "[SERVER]: You have just registered to our server! You have been automatically logged in!");
? ? ? ? ? ? result = db_query(db_handle, "SELECT last_insert_rowid()");
? ? ? ? ? ? gUserData[playerid][USER_ID] = db_get_field_int(result);
? ? ? ? ? ? db_free_result(result);
? ? ? ? }
? ? }
? ? return 1;
}
Code isn't working:
Code:
gUserData[playerid][USER_PASSWORD] = inputtext[strlen(inputtext)];? ? ? ? ? ?
? ? ? ? ? ? format(query, sizeof query, "INSERT INTO users (nickname, password) VALUES ('%q', '%s')", gUserData[playerid][USER_NICKNAME], gUserData[playerid][USER_PASSWORD]);
The password field on the database is empty, and other values are ok. No error has given from the compiler.