Help data won't load from MySQL
#1

Hey all, i have some problem when load player data from database.
Please help me, i can't fix it.
There's the script.
Код:
stock LoadPlayerInfo(playerid)
{
	new
		Query[67],dkills, ddeaths, dmoney, dlevel, dexp, dexpL, pname[16];
	mysql_real_escape_string(pName(playerid), pname);

    format(Query, sizeof(Query), "SELECT `kills`,`deaths`,`money`,`Level`,`EXP`,`EXP_L` FROM `playerinfo` WHERE `user` = '%s'", pname);
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row(Query))
        {
            sscanf(Query, "p<|>iffff", dkills, ddeaths, dmoney, dlevel, dexp, dexpL);
			PVar[playerid][pKills] = dkills;
			PVar[playerid][pDeaths] = ddeaths;
			GivePlayerMoney(playerid, dmoney);
			PVar[playerid][pLevel] = dlevel;
			PVar[playerid][pExp] = dexp;
			PVar[playerid][pExpL] = dexpL;
		}
    }

	format(Msg, sizeof(Msg), "DATA : %d %d %d %d %d %d", dkills, ddeaths, dmoney, dlevel, dexp, dexpL);
	SendClientMessage(playerid, COLOR_CADETBLUE, Msg);
    mysql_free_result();
    
	return 1;
}
Can you help me to fix it?
Thanks
Reply
#2

More info(s)?
Reply
#3

What does the mysq log say?

Also a few tips:
You don't need to check if mysql_num_rows, the while loop will only run if there are any as mysql_fetch_field moves the internal cursor or returns 0 if there are no more rows.
Why are the size of player name variable is only 16? You should use the constant MAX_PLAYER_NAME
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)