[ERROR] Mysql Can't save data player
#1

this error
pawn Код:
[23:59:14] [DEBUG] mysql_format - connection: 1, len: 512, format: "%s pAdminMapping = %d pDonateLevel = %d pZmc = %d pMapsPlayed = %d pMoney = %d pIP = %s pBanned = %d gLeader = %d gMember = %d p..."
[23:59:14] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE zmusers SET pEXP = 0 pKills = 0 pDeaths = 1 pRank = 0 pEv", callback: "(null)", format: "(null)"
[23:59:14] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[23:59:14] [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 'pKills = 0 pDeaths = 1 pRank = 0 pEvac = 0 pAdminLevel = 0 pAdminMapping = 0 pDo' at line 1
[23:59:14] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError
this my custom function
pawn Код:
stock SaveStats(playerid)
{
    new IP[16];
    GetPlayerIp(playerid, IP, sizeof(IP));
    new query[512];
    format(query, sizeof(query), "UPDATE zmusers SET pEXP = %d pKills = %d pDeaths = %d pRank = %d pEvac = %d pAdminLevel = %d",
    pInfo[playerid][pEXP], pInfo[playerid][pKills], pInfo[playerid][pDeaths], pInfo[playerid][pRank], pInfo[playerid][pEvac], pInfo[playerid][pAdminLevel]);
    mysql_format(mysql, query, sizeof(query), "%s pAdminMapping = %d pDonateLevel = %d pZmc = %d pMapsPlayed = %d pMoney = %d pIP = %s pBanned = %d gLeader = %d gMember = %d pWarnings = %d",
    query, pInfo[playerid][pAdminMapping], pInfo[playerid][pDonateLevel],  pInfo[playerid][pZmc], pInfo[playerid][pMapsPlayed], pInfo[playerid][pMoney], IP, pInfo[playerid][pBanned],  pInfo[playerid][gLeader], pInfo[playerid][gMember], pInfo[playerid][pWarnings]);
    mysql_tquery(mysql, query, "", "");
    return 1;
}
where i wrong?
Reply
#2

You must put ` in your format look on my script, I am using SQLite, check it and tell if its fixed

Код:
format(Query, 300, "UPDATE `users` SET `password` = '%s' WHERE `username` = '%s'", DB_Escape(Buf), DB_Escape(data[playerid][pName]));
db_query(Database, Query);
^ this part is from change pass btw
Reply
#3

ok wait i will try it
Reply
#4

Quote:
Originally Posted by kloning1
Посмотреть сообщение
ok wait i will try it
Код:
"You have an error in your SQL syntax"
This is why I posted this

-EDIT-

Thats the correct code I think

Код:
			format(query, sizeof(query), "UPDATE `zmusers` SET `pEXP` = `%d`, `pKills` = `%d`, `pDeaths` = `%d`, `pRank` = `%d`, `pEvac` = `%d`, `pAdminLevel` = `%d`",
			pInfo[playerid][pEXP], pInfo[playerid][pKills], pInfo[playerid][pDeaths], pInfo[playerid][pRank], pInfo[playerid][pEvac], pInfo[playerid][pAdminLevel]);
Reply
#5

Quote:
Originally Posted by SecretBoss
Посмотреть сообщение
You must put ` in your format
No, you don't. You only use these if your column or table name is a MySQL keyword. And if that's the case then you should really think about changing the name, anyway. Backticks needlessly complicate, lengthen and obfuscate the query.
Reply
#6

Quote:
Originally Posted by SecretBoss
Посмотреть сообщение
Код:
"You have an error in your SQL syntax"
This is why I posted this

-EDIT-

Thats the correct code I think

Код:
			format(query, sizeof(query), "UPDATE `zmusers` SET `pEXP` = `%d`, `pKills` = `%d`, `pDeaths` = `%d`, `pRank` = `%d`, `pEvac` = `%d`, `pAdminLevel` = `%d`",
			pInfo[playerid][pEXP], pInfo[playerid][pKills], pInfo[playerid][pDeaths], pInfo[playerid][pRank], pInfo[playerid][pEvac], pInfo[playerid][pAdminLevel]);
I've combine with mysql_format, and add WHERE `Username` = '%e`
but no result
pawn Код:
stock SaveStats(playerid)
{
    new IP[16];
    GetPlayerIp(playerid, IP, sizeof(IP));
    new query[512];
    mysql_format(mysql, query, sizeof(query), "UPDATE `zmusers` SET `pEXP` = %d `pKills` = %d `pDeaths` = %d `pRank` = %d `pEvac` = %d `pAdminLevel` = %d `pAdminMapping` = %d `pDonateLevel` = %d `pZmc` = %d `pMapsPlayed` = %d `pMoney` = %d `pIP` = `%s` `pBanned` = %d `gLeader` = %d `gMember` = %d `pWarnings` = %d WHERE `Username` = '%e'",
    pInfo[playerid][pEXP], pInfo[playerid][pKills], pInfo[playerid][pDeaths], pInfo[playerid][pRank], pInfo[playerid][pEvac], pInfo[playerid][pAdminLevel], pInfo[playerid][pAdminMapping], pInfo[playerid][pDonateLevel],  pInfo[playerid][pZmc], pInfo[playerid][pMapsPlayed], pInfo[playerid][pMoney], IP, pInfo[playerid][pBanned],  pInfo[playerid][gLeader], pInfo[playerid][gMember], pInfo[playerid][pWarnings], PlayerName(playerid));
    mysql_tquery(mysql, query);
    return 1;
}
Reply
#7

OK! SCRIPT SOLVED! by myself

thank
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)