Saving fightsyles mysql
#1

I am trying to players fightstyles as my mysql

But this

PHP код:
21:18:13] [DEBUGmysql_format connection1len128format"WHERE `ID`= %d AND `Username`= '%e'"
[21:18:13] [DEBUGmysql_tquery connection1query"UPDATE `players` SET `Admin`=4, `Donator`=0, `RegularPlayer`=0, "callback"(null)"format"(null)"
[21:18:13] [DEBUGCMySQLQuery::Execute[] - starting query execution
[21:18:13] [ERRORCMySQLQuery::Execute[] - (error #1064) Erreur de syntaxe prиs de '`FightStyles`=1' а la ligne 1
[21:18:13] [DEBUGCMySQLQuery::Execute[] - error will be triggered in OnQueryError 
PHP код:
public SavePlayerData(playerid)
{
    new 
query[2316];
    new 
tmp[128];
    
pData[playerid][pFightStyles] = FightStyleID{playerid};
            
    if(
IsLoggedIn[playerid] == && playerid != INVALID_PLAYER_ID && !IsPlayerNPC(playerid))
    {
        
format(querysizeof(query), "UPDATE `players` SET " );
        
        
format(tmpsizeof(tmp), "`FightStyles`=%d "pData[playerid][pFightStyles] );
        
strcat(querytmp);
        
mysql_format(mysqltmpsizeof(tmp), "WHERE `ID`= %d AND `Username`= '%e'"pData[playerid][pID],  Name[playerid] );
        
mysql_tquery(mysqlquery"""");
        
printf("Query:%s"query);
    }
    return 
1;

Reply
#2

Try this:

pawn Код:
public SavePlayerData(playerid)
{
    new query[128];
    pData[playerid][pFightStyles] = GetPlayerFightingStyle(playerid);

    if(IsLoggedIn[playerid] == 1 && playerid != INVALID_PLAYER_ID && !IsPlayerNPC(playerid))
    {
        mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `FightStyles`=%d WHERE `Username`='%s'", pData[playerid][pFightStyles], Name[playerid]);
        mysql_tquery(mysql, query, "", "");
        printf("Query:%s", query);
    }
    return 1;
}
Or maybe FightStyle's structure is not in INT format.
Reply
#3

PHP код:
public SavePlayerData(playerid)
{
    new 
query[128];
    
pData[playerid][pFightStyles] = GetPlayerFightingStyle(playerid);

    if(
IsLoggedIn[playerid] == && playerid != INVALID_PLAYER_ID && !IsPlayerNPC(playerid))
    {
        
mysql_format(mysqlquerysizeof(query), "UPDATE `players` SET `FightStyles`=%d WHERE `Username`='%s'"pData[playerid][pFightStyles], Name[playerid]);
        
mysql_query(mysqlquery);
        
printf("Query:%s"query);
    }
    return 
1;

Try this too.
Reply
#4

According to your log, you are not showing us the whole code.

Also, for the WHERE part, you format "tmp" and never concatenate it with you "query" variable.
Reply
#5

I am using stract. If i use mysql_format for Update then my others things doesn't work.

here's some codes:

PHP код:
public SavePlayerData(playerid)
{
    new 
query[2316];
    new 
tmp[128];
    
pData[playerid][pFightStyles] = FightStyleID{playerid};
            
    if(
IsLoggedIn[playerid] == && playerid != INVALID_PLAYER_ID && !IsPlayerNPC(playerid))
    {
        
format(querysizeof(query), "UPDATE `players` SET " );
        
        
format(tmpsizeof(tmp), "`Admin`=%d, "pData[playerid][pAdmin] );
        
strcat(querytmp);
        
format(tmpsizeof(tmp), "`Minutes`=%d, "pData[playerid][pMinutes] );
        
strcat(querytmp);
        
format(tmpsizeof(tmp), "`Hours`=%d, "pData[playerid][pHours] );
        
strcat(querytmp);
        
format(tmpsizeof(tmp), "`vLock`=%d "pData[playerid][pLock] );
        
strcat(querytmp);
        
        
format(tmpsizeof(tmp), "`FightStyles`=%d "pData[playerid][pFightStyles] );
        
strcat(querytmp);
        
mysql_format(mysqltmpsizeof(tmp), "WHERE `ID`= %d AND `Username`= '%e'"pData[playerid][pID],  Name[playerid] );
        
mysql_tquery(mysqlquery"""");
        
printf("Query:%s"query);
    }
    return 
1;
}
//let's load player's information
public OnAccountLoad(playerid)
{
    
SetPlayerColor(playerid, -1);
    
pData[playerid][pFightStyles] = cache_get_field_content_int(0"FightStyles");
    
IsLoggedIn[playerid] = 1;
    
SendClientMessage(playeridCOLOR_CYAN"You have been logged in, Continue your current life.");
    return 
1;

Reply
#6

So, try changing FightStyleID{playerid} to GetPlayerFightingStyle(playerid).
Reply
#7

pawn Код:
public SavePlayerData(playerid)
{
    new query[2316];
    new tmp[128];
    pData[playerid][pFightStyles] = FightStyleID{playerid};
             
    if(IsLoggedIn[playerid] == 1 && playerid != INVALID_PLAYER_ID && !IsPlayerNPC(playerid))
    {
        format(query, sizeof(query), "UPDATE `players` SET " );
         
        format(tmp, sizeof(tmp), "`Admin`=%d, ", pData[playerid][pAdmin] );
        strcat(query, tmp);

        format(tmp, sizeof(tmp), "`Minutes`=%d, ", pData[playerid][pMinutes] );
        strcat(query, tmp);

        format(tmp, sizeof(tmp), "`Hours`=%d, ", pData[playerid][pHours] );
        strcat(query, tmp);

        format(tmp, sizeof(tmp), "`vLock`=%d, ", pData[playerid][pLock] );
        strcat(query, tmp);
         
        format(tmp, sizeof(tmp), "`FightStyles`=%d ", pData[playerid][pFightStyles] );
        strcat(query, tmp);

        mysql_format(mysql, tmp, sizeof(tmp), "WHERE `ID`= %d AND `Username`= '%e'", pData[playerid][pID],  Name[playerid] );
        strcat(query, tmp);
        mysql_tquery(mysql, query, "", "");
        printf("Query:%s", query);
    }
    return 1;
}
There was a missing comma after vlock.
Reply
#8

Thanks lol ^^. How the f**K i can miss it.! thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)