Mysql R39-2 save problem
#1

Hi, i have a small problem with mysql R39-2 and i need some help's

PHP код:
forward PlayerFile_Save(playerid);
public 
PlayerFile_Save(playerid)
{
    new 
query[1024];
    
strcat(databasequerysizeof(query), "UPDATE users SET Password = %s, Level = %d, \
    VIP = %d, Jailed = %d, Wanted = %d, \
    Bans = %d, BanTime = %d, TruckerLicense = %d, \
    BusLicense = %d, PilotLicense = %d, \
    MafiaLicense = %d, Muted = %d, \
    RulesRead = %d, StatsMetersDriven = %d, \
    StatsTruckerJobs = %d, StatsConvoyJobs = %d, \
    StatsBusDriverJobs = %d, StatsPilotJobs = %d, \
    StatsMafiaJobs = %d, StatsMafiaStolen = %d, \
    StatsPoliceFined = %d, StatsPoliceJailed = %d, \
    StatsCourierJobs = %d, StatsRoadworkerJobs = %d, \ 
    StatsAssistance = %d, Team = %d, Leader = %d, \
    Money = %d, Score = %d WHERE ID = %e"
APlayerData[playerid][PlayerPassword],APlayerData[playerid][PlayerLevel],APlayerData[playerid][VIPLevel],APlayerData[playerid][PlayerJailed],GetPlayerWantedLevel(playerid),
    
APlayerData[playerid][Bans],APlayerData[playerid][BanTime],APlayerData[playerid][TruckerLicense],APlayerData[playerid][BusLicense],APlayerData[playerid][PilotLicense],APlayerData[playerid][MafiaLicense],APlayerData[playerid][Muted],
    
APlayerData[playerid][RulesRead],APlayerData[playerid][StatsMetersDriven],APlayerData[playerid][StatsTruckerJobs],APlayerData[playerid][StatsConvoyJobs],APlayerData[playerid][StatsBusDriverJobs],
    
APlayerData[playerid][StatsPilotJobs],APlayerData[playerid][StatsMafiaJobs],APlayerData[playerid][StatsMafiaStolen],APlayerData[playerid][StatsPoliceFined],APlayerData[playerid][StatsPoliceFined],
    
APlayerData[playerid][StatsPoliceJailed],APlayerData[playerid][StatsCourierJobs],APlayerData[playerid][StatsRoadworkerJobs],APlayerData[playerid][StatsAssistance],APlayerData[playerid][Team],
    
APlayerData[playerid][Leader],APlayerData[playerid][PlayerMoney],APlayerData[playerid][PlayerScore],APlayerData[playerid][CompteID]);
    
mysql_tquery(databasequery);
    
printf("SERVER STATS : ACCOUNT HAVE BEEN SAVED.");
    return 
1;

errors :

Quote:

(61) : error 075: input line too long (after substitutions)
(62) : error 035: argument type mismatch (argument 1)
(62) : error 035: argument type mismatch (argument 2)
(62) : error 017: undefined symbol "UPDATE"
(62) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


5 Errors.

line 61 and 62

PHP код:
    StatsPoliceFined = %dStatsPoliceJailed = %d, \
    
StatsCourierJobs = %dStatsRoadworkerJobs = %d, \ 
when i use mysql_format

Quote:

error 075: input line too long (after substitutions)
error 037: invalid string (possibly non-terminated string)
error 017: undefined symbol "UPDATE"
error 017: undefined symbol "users"
fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


5 Errors.

Thx.
Reply
#2

<Deleted>
Reply
#3

It should worked, your problem same with me.
Код:
    new query[1024]; 
    format(query, sizeof(query), "UPDATE `users` SET `Password` = '%s', `Level` = %d,", APlayerData[playerid][PlayerPassword], APlayerData[playerid][PlayerLevel]);
    format(query, sizeof(query), "%s `VIP` = %d, `Jailed` = %d, `Wanted` = %d,", query, APlayerData[playerid][VIPLevel], APlayerData[playerid][PlayerJailed], GetPlayerWantedLevel(playerid));
    format(query, sizeof(query), "%s `Bans` = %d, `BanTime` = %d, `TruckerLicense` = %d,", query, APlayerData[playerid][Bans], APlayerData[playerid][BanTime], APlayerData[playerid][TruckerLicense]);
    format(query, sizeof(query), "%s `BusLicense` = %d, `PilotLicense` = %d,", query, APlayerData[playerid][BusLicense], APlayerData[playerid][PilotLicense]);
    format(query, sizeof(query), "%s `MafiaLicense` = %d, `Muted` = %d,", query, APlayerData[playerid][MafiaLicense], APlayerData[playerid][Muted]);
    format(query, sizeof(query), "%s `RulesRead` = %d, `StatsMetersDriven` = %d,", query, APlayerData[playerid][RulesRead], APlayerData[playerid][StatsMetersDriven]);
    format(query, sizeof(query), "%s `StatsTruckerJobs` = %d, `StatsConvoyJobs` = %d,", query, APlayerData[playerid][StatsTruckerJobs], APlayerData[playerid][StatsConvoyJobs]);
    format(query, sizeof(query), "%s `StatsBusDriverJobs` = %d, `StatsPilotJobs` = %d,", query, APlayerData[playerid][StatsBusDriverJobs], APlayerData[playerid][StatsPilotJobs]);
    format(query, sizeof(query), "%s `StatsMafiaJobs` = %d, `StatsMafiaStolen` = %d,", query, APlayerData[playerid][StatsMafiaJobs], APlayerData[playerid][StatsMafiaStolen]);
    format(query, sizeof(query), "%s `StatsPoliceFined` = %d, `StatsPoliceJailed` = %d,", query, APlayerData[playerid][StatsPoliceFined], APlayerData[playerid][StatsPoliceJailed]);
    format(query, sizeof(query), "%s `StatsCourierJobs` = %d, `StatsRoadworkerJobs` = %d,", query, APlayerData[playerid][StatsCourierJobs], APlayerData[playerid][StatsRoadworkerJobs]);
    format(query, sizeof(query), "%s `StatsAssistance` = %d, `Team` = %d, `Leader` = %d,", query, APlayerData[playerid][StatsAssistance], APlayerData[playerid][Team], APlayerData[playerid][Leader]);
    format(query, sizeof(query), "%s `Money` = %d, `Score` = %d WHERE `ID` = %d,", query, APlayerData[playerid][PlayerMoney], APlayerData[playerid][PlayerScore], APlayerData[playerid][CompteID]);
    mysql_format(database, query, sizeof(query), "%s", query);
    mysql_tquery(database, query); 
    printf("DEBUG : %s", query);
you need to escape string with quotes in SQL syntax
Reply
#4

The error is fixed, thank you +REP

but now i have a problиme IG, when i'am disconnecting nothing happen , the callback is called but nothing happen , the stats stay in the same

mysql_debug

Quote:

[03:00:54] [DEBUG] mysql_format - connection: 1, len: 1024, format: "%s"
[03:00:54] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `users` SET `Password` = '', `Level` = 0, `VIP` = 0, `Jai", callback: "(null)", format: "(null)"
[03:00:54] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[03:00:54] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
[03:00:54] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError

they have something wrong because i'am level 7 IG i'am not level 0

this is my load callback

PHP код:
forward PlayerFile_Load(playerid);
public 
PlayerFile_Load(playerid)
{
    new 
str[24];
    
APlayerData[playerid][StatsAssistance] = cache_get_field_content_int(0"StatsAssistance");
    
APlayerData[playerid][PlayerPassword] = cache_get_field_content(0"Password"str);
    
APlayerData[playerid][PlayerLevel] = cache_get_field_content_int(0"Level");
    
APlayerData[playerid][VIPLevel] = cache_get_field_content_int(0"VIP");
    
APlayerData[playerid][PlayerJailed] = cache_get_field_content_int(0"Jailed");
    
APlayerData[playerid][Bans] = cache_get_field_content_int(0"Bans");
    
APlayerData[playerid][BanTime] = cache_get_field_content_int(0"BanTime");
    
APlayerData[playerid][TruckerLicense] = cache_get_field_content_int(0"TruckerLicense");
    
APlayerData[playerid][BusLicense] = cache_get_field_content_int(0"BusLicense");    
    
APlayerData[playerid][PilotLicense] = cache_get_field_content_int(0"PilotLicense");    
    
APlayerData[playerid][MafiaLicense] = cache_get_field_content_int(0"MafiaLicense");    
    
APlayerData[playerid][Team] = cache_get_field_content_int(0"Team");    
    
APlayerData[playerid][Leader] = cache_get_field_content_int(0"Leader");
    
APlayerData[playerid][StatsMetersDriven] = cache_get_field_content_int(0"StatsMetersDriven");
    
APlayerData[playerid][StatsTruckerJobs] = cache_get_field_content_int(0"StatsTruckerJobs");
    
APlayerData[playerid][StatsConvoyJobs] = cache_get_field_content_int(0"StatsConvoyJobs");
    
APlayerData[playerid][StatsBusDriverJobs] = cache_get_field_content_int(0"StatsBusDriverJobs");
    
APlayerData[playerid][StatsPilotJobs] = cache_get_field_content_int(0"StatsPilotJobs");
    
APlayerData[playerid][StatsMafiaJobs] = cache_get_field_content_int(0"StatsMafiaJobs");
    
APlayerData[playerid][StatsMafiaStolen] = cache_get_field_content_int(0"StatsMafiaStolen");
    
APlayerData[playerid][StatsPoliceFined] = cache_get_field_content_int(0"StatsPoliceFined");
    
APlayerData[playerid][StatsPoliceJailed] = cache_get_field_content_int(0"StatsPoliceJailed");
    
APlayerData[playerid][StatsCourierJobs] = cache_get_field_content_int(0"StatsCourierJobs");
    
APlayerData[playerid][StatsRoadworkerJobs] = cache_get_field_content_int(0"StatsRoadworkerJobs");
    
APlayerData[playerid][PlayerMoney] = cache_get_field_content_int(0"Money");
    
APlayerData[playerid][PlayerScore] = cache_get_field_content_int(0"Score");
    
printf("SERVER STATS: ACCOUNT HAVE BEEN LOADED");
    return 
1;

Reply
#5

Can you show the output of this code?
Код:
printf("DEBUG : %s", query);
Reply
#6

yes,
i have tried to connect and change some stats ( money and others things ... ) and disconnect to check if that work but the database still have the same informations, i have change the Money value and score value and Level value

Quote:

[03:15:10] DEBUG : UPDATE `users` SET `Password` = '', `Level` = 0, `VIP` = 0, `Jailed` = 0, `Wanted` = 0, `Bans` = 0, `BanTime` = 0, `TruckerLicense` = 0, `BusLicense` = 0, `PilotLicense` = 0, `MafiaLicense` = 0, `Muted` = 0, `RulesRead` = 0, `StatsMetersDriven` = 0, `StatsTruckerJobs` = 0, `StatsConvoyJobs` = 0, `StatsBusDriverJobs` = 0, `StatsPilotJobs` = 0, `StatsMafiaJobs` = 0, `StatsMafiaStolen` = 0, `StatsPoliceFined` = 0, `StatsPoliceJailed` = 0, `StatsCourierJobs` = 0, `StatsRoadworkerJobs` = 0, `StatsAssistance` = 0, `Team` = 0, `Leader` = 0, `Money` = 0, `Score` = 0 WHERE `ID` = 6,
[03:15:10] [part] Black has left the server (0:1)

Reply
#7

You're wrong when loaded player password, here's the right code.
But this isn't your problem.
Код:
forward PlayerFile_Load(playerid); 
public PlayerFile_Load(playerid) 
{ 
    new str[24]; 
    APlayerData[playerid][StatsAssistance] = cache_get_field_content_int(0, "StatsAssistance"); 
    cache_get_field_content(0, "Password", str); 
    format(APlayerData[playerid][PlayerPassword], 24, "%s", str);
    APlayerData[playerid][PlayerLevel] = cache_get_field_content_int(0, "Level"); 
    APlayerData[playerid][VIPLevel] = cache_get_field_content_int(0, "VIP"); 
    APlayerData[playerid][PlayerJailed] = cache_get_field_content_int(0, "Jailed"); 
    APlayerData[playerid][Bans] = cache_get_field_content_int(0, "Bans"); 
    APlayerData[playerid][BanTime] = cache_get_field_content_int(0, "BanTime"); 
    APlayerData[playerid][TruckerLicense] = cache_get_field_content_int(0, "TruckerLicense"); 
    APlayerData[playerid][BusLicense] = cache_get_field_content_int(0, "BusLicense");     
    APlayerData[playerid][PilotLicense] = cache_get_field_content_int(0, "PilotLicense");     
    APlayerData[playerid][MafiaLicense] = cache_get_field_content_int(0, "MafiaLicense");     
    APlayerData[playerid][Team] = cache_get_field_content_int(0, "Team");     
    APlayerData[playerid][Leader] = cache_get_field_content_int(0, "Leader"); 
    APlayerData[playerid][StatsMetersDriven] = cache_get_field_content_int(0, "StatsMetersDriven"); 
    APlayerData[playerid][StatsTruckerJobs] = cache_get_field_content_int(0, "StatsTruckerJobs"); 
    APlayerData[playerid][StatsConvoyJobs] = cache_get_field_content_int(0, "StatsConvoyJobs"); 
    APlayerData[playerid][StatsBusDriverJobs] = cache_get_field_content_int(0, "StatsBusDriverJobs"); 
    APlayerData[playerid][StatsPilotJobs] = cache_get_field_content_int(0, "StatsPilotJobs"); 
    APlayerData[playerid][StatsMafiaJobs] = cache_get_field_content_int(0, "StatsMafiaJobs"); 
    APlayerData[playerid][StatsMafiaStolen] = cache_get_field_content_int(0, "StatsMafiaStolen"); 
    APlayerData[playerid][StatsPoliceFined] = cache_get_field_content_int(0, "StatsPoliceFined"); 
    APlayerData[playerid][StatsPoliceJailed] = cache_get_field_content_int(0, "StatsPoliceJailed"); 
    APlayerData[playerid][StatsCourierJobs] = cache_get_field_content_int(0, "StatsCourierJobs"); 
    APlayerData[playerid][StatsRoadworkerJobs] = cache_get_field_content_int(0, "StatsRoadworkerJobs"); 
    APlayerData[playerid][PlayerMoney] = cache_get_field_content_int(0, "Money"); 
    APlayerData[playerid][PlayerScore] = cache_get_field_content_int(0, "Score"); 

    printf("SERVER STATS: ACCOUNT HAVE BEEN LOADED"); 
    return 1; 
}
and i see all variables is 0 except `ID`
can you show me mysql query for PlayerFile_Load(playerid) ?
Reply
#8

i have load password in the query , okay take a look

OnPlayerConnect

pawn Код:
new query[128];
    mysql_format(database, query, sizeof(query),"SELECT `Password`, `ID` FROM `users` WHERE `PlayerName` = '%e' LIMIT 1", GetPlayerNameEx(playerid));
    mysql_tquery(database, query, "OnAccountCheck", "i", playerid);
OnAccountCheck

pawn Код:
public OnAccountCheck(playerid)
{
    new rows, fields;
    cache_get_data(rows, fields, database);
    if(rows)
    {
        cache_get_field_content(0, "Password", APlayerData[playerid][PlayerPassword], database, 129);
        APlayerData[playerid][CompteID] = cache_get_field_content_int(0, "ID");
        printf("%s", APlayerData[playerid][PlayerPassword]);
        ShowPlayerDialog(playerid, DialogLogin, DIALOG_STYLE_PASSWORD, TXT_DialogLoginTitle, TXT_DialogLoginMsg, TXT_DialogLoginButton1, TXT_DialogButtonCancel);
    }
    else
    {
        new strStartRules[2000];

        ShowPlayerDialog(playerid, DialogStartRules, DIALOG_STYLE_MSGBOX, "Rиglement du serveur", strStartRules, "Refuser", "Accepter");
    }
    printf("SERVER STATS : ACCOUNT CHECK");
    return 1;
}
Reply
#9

Anyone pls?
Reply
#10

pawn Код:
format(query, sizeof(query), "%s `Money` = %d, `Score` = %d WHERE `ID` = %d,", query, APlayerData[playerid][PlayerMoney], APlayerData[playerid][PlayerScore], APlayerData[playerid][CompteID]);
See this little comma at the end? Well, it screwes up everything:

pawn Код:
format(query, sizeof(query), "%s `Money` = %d, `Score` = %d WHERE `ID` = %d", query, APlayerData[playerid][PlayerMoney], APlayerData[playerid][PlayerScore], APlayerData[playerid][CompteID]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)