27.11.2013, 16:30
Hey all! I have a problem with loading data from my table.
I got table 'users' which contains 311 fields. I've created so far login and register system in my GM but I have one major problem. After player logs in, system loads data from fields "Age" and "Gender" so it can check if the player has completed the tutorial or not. But I have no idea why it won't load anything from that two fields. This is my code:
And one more thing. Two fields that I mentioned, Age and Gender are not written with upper case, but when I try to write Age (db_get_field_assoc(result, "Age"..) with lower case, my server crashes. I really don't know how to fix this, so can somebody please help me? I appreciate it.
I got table 'users' which contains 311 fields. I've created so far login and register system in my GM but I have one major problem. After player logs in, system loads data from fields "Age" and "Gender" so it can check if the player has completed the tutorial or not. But I have no idea why it won't load anything from that two fields. This is my code:
pawn Код:
WP_Hash(password, sizeof(password), inputtext);
format(string, sizeof(string), "SELECT * FROM `USERS` WHERE `NAME`='%s' AND `PASSWORD`='%s'", DB_Escape(RPN(playerid)), password);
result = db_query(UserDatabase, string);
if(db_num_rows(result) > 0) // so far everything works just fine
{
new szValue[64];
db_get_field_assoc(result, "AGE", szValue, 3);
PlayerInfo[playerid][pAge] = strval(szValue);
db_get_field_assoc(result, "GENDER", szValue, 6);
PlayerInfo[playerid][pGender] = strval(szValue);
if(!PlayerInfo[playerid][pGender] || !PlayerInfo[playerid][pAge])
{
ShowDialog(playerid, 3);
}
else
{
LoadChar(playerid);
SpawnPlayer(playerid);
}