LoginPlayer(playerid) { new Query[100], DBResult: Result2; format(Query, sizeof(Query), "SELECT username FROM users WHERE username = '%s' LIMIT 0, 1", Nick(playerid)); Result2 = db_query(Database, Query); if(db_num_rows(Result2)) { PlayerInfo[playerid][IID] = db_get_field_assoc_int(Result2, "userid"); PlayerInfo[playerid][Level] = db_get_field_assoc_int(Result2, "admin"); PlayerInfo[playerid][pVip] = db_get_field_assoc_int(Result2, "vip"); PlayerInfo[playerid][Money] = db_get_field_assoc_int(Result2, "money"); PlayerInfo[playerid][Score] = db_get_field_assoc_int(Result2, "score"); PlayerInfo[playerid][Kills] = db_get_field_assoc_int(Result2, "kills"); PlayerInfo[playerid][Deaths] = db_get_field_assoc_int(Result2, "deaths"); PlayerInfo[playerid][DGanados] = db_get_field_assoc_int(Result2, "dwin"); PlayerInfo[playerid][DPerdidos] = db_get_field_assoc_int(Result2, "dlost"); PlayerInfo[playerid][Experiencia] = db_get_field_assoc_int(Result2, "exp"); PlayerInfo[playerid][hourss] = db_get_field_assoc_int(Result2, "hours"); PlayerInfo[playerid][mins] = db_get_field_assoc_int(Result2, "mins"); PlayerInfo[playerid][secs] = db_get_field_assoc_int(Result2, "secs"); PlayerH[playerid][Spawn] = db_get_field_assoc_int(Result2, "pSpawn"); PlayerH[playerid][Houseid] = db_get_field_assoc_int(Result2, "HouseID"); PlayerInfo[playerid][Registered] = 1; PlayerInfo[playerid][LoggedIn] = 1; SetPlayerMoney(playerid, PlayerInfo[playerid][Money]); SetPlayerScore(playerid, PlayerInfo[playerid][Score]); } db_free_result(Result2); }
SELECT * FROM `users` WHERE `username` = '%s' LIMIT 1
You are only selecting one field i.e. "username" in the query. So expect only one field's result.
And your query is pretty much all messed up. - No use of "`" for table and column names - LIMIT having multiple values Corrected query: pawn Код:
|
Now working, thanks you a lot!! But one question, if im expecting only one field, then why i have to put "LIMIT 1"?
|
Ok, but i need in this case to put "LIMIT 1" necessarily? Because as you said, i'm only expecting 1 row because there is only 1 username with that nick at all the table. I'm asking this because i have other querys in which i don't use LIMIT 1.
Thanks. |