MYSQL Saving
#9

Your previous version was missing a comma, your current version has to much comma's

Try this:
Код:
public OnPlayerSave(playerid)
{
    new query[500];
    if(IsLoggedIn[playerid] == 1 && playerid != INVALID_PLAYER_ID && !IsPlayerNPC(playerid))
    {
        format(query, sizeof(query), 
		"UPDATE `players` SET `Money`='%d', `Score`='%d', `Medical`='%d' WHERE `ID`='%d' AND `user`= '%e'", 
		GetPlayerMoney(playerid), 
		GetPlayerScore(playerid), 
		pInfo[playerid][pMedical],
		pInfo[playerid][pID],
		PlayerName(playerid)
	);
        mysql_tquery(MySQLCon, query, "", "");
    }
    return 1;
}
Comments:
- Not sure what mysql_tquery must be, but pretty sure its a typo, and it should be mysql_query instead.
- "Money" "Score" "Medical" and "ID" columns might not have any capitals, like "user"? double-check the column names if the above doesnt work

Alternatively, you may just want the code you pasted fixed, see the below for that:
Код:
public OnPlayerSave(playerid)
{
    new query[500];
    new tmp[64];
    if(IsLoggedIn[playerid] == 1 && playerid != INVALID_PLAYER_ID && !IsPlayerNPC(playerid))
    {
        format(query, sizeof(query), "UPDATE `players` SET " );
       
        format(tmp, sizeof(tmp), "`Money`='%d', ", GetPlayerMoney(playerid) );
        strcat(query, tmp);
        
        format(tmp, sizeof(tmp), "`Score`='%d', ", GetPlayerScore(playerid) );
        strcat(query, tmp);
        
        format(tmp, sizeof(tmp), "`Medical`='%d' ", pInfo[playerid][pMedical] );
        strcat(query, tmp);
        
        format(tmp, sizeof(tmp), "WHERE `ID`= %d AND `user`= '%e'", pInfo[playerid][pID], PlayerName(playerid) );
        strcat(query, tmp);
        mysql_tquery(MySQLCon, query, "", "");
    }
    return 1;
}
Compare the "Money", "Score" and "Medical" lines with the ones from your example, ive added single-quotation marks (') and removed the comma you added too the end of "Medical"
Reply


Messages In This Thread
MYSQL Saving - by STONEGOLD - 29.06.2015, 23:39
Re: MYSQL Saving - by nezo2001 - 29.06.2015, 23:48
Re: MYSQL Saving - by kloning1 - 30.06.2015, 05:38
Re: MYSQL Saving - by Cheesus - 30.06.2015, 08:33
Re: MYSQL Saving - by STONEGOLD - 30.06.2015, 09:25
Re: MYSQL Saving - by STONEGOLD - 30.06.2015, 10:15
Re: MYSQL Saving - by Suicidal.Banana - 30.06.2015, 10:32
Re: MYSQL Saving - by STONEGOLD - 30.06.2015, 10:37
Re: MYSQL Saving - by Suicidal.Banana - 30.06.2015, 11:08
Re: MYSQL Saving - by STONEGOLD - 30.06.2015, 11:11

Forum Jump:


Users browsing this thread: 1 Guest(s)