14.03.2017, 20:06
Hello, I'm making a registration system from scratch and I have a trouble. I'm trying to check if the username already exists on database but always return that the user is not registred.
Example: I enter as TestUser but in DB, `players` table, already contains a user called TestUser (`username`), and says that the name is avaliable and I can register with this name, here is the code:
SOLVED. Just changed mysql_tquery to mysql_query.
Example: I enter as TestUser but in DB, `players` table, already contains a user called TestUser (`username`), and says that the name is avaliable and I can register with this name, here is the code:
Код:
public CheckForRegister(name[], playerid) { new query2[240]; mysql_format(handle, query2, sizeof(query2), "SELECT * FROM `players` WHERE `username` = '%s'", name); mysql_tquery(handle, query2, "", ""); // No errors on mysql_log, the query executes right cache_get_data(rows, fields, handle); if(rows) // made a printf and rows = 0 but there is a user called same! { new content[256]; format(content, sizeof(content),"{FFFFFF}Username in use.\nTell another name:"); ShowPlayerDialog(playerid, DIALOG_PLAYER_ADD, DIALOG_STYLE_INPUT, "Register", content, "Next", ""); } else { // INSERT INTO PLAYERS ETC. ALWAYS IM GETTING HERE. ROWS COUNT ARE 0 BUT IN DB I HAVE ONE USER CALLED TestUser } }