Mysql errors
#1

Hello, I have add some new things in the mysql under players.
When I join the server and give myself all those things and log out I will get errors inside the console/serverlogs


Код:
case THREAD_SAVE_ACCOUNT_CHAIN_5: {
	        // Escape more strings...
	        new
	            szMarriedTo[MAX_PLAYER_NAME],
	            szFlag[128],
	            szReferredBy[MAX_PLAYER_NAME];
	            
			mysql_real_escape_string(PlayerInfo[extraid][pMarriedTo], szMarriedTo, g_MySQLConnections[0]);
			mysql_real_escape_string(PlayerInfo[extraid][pFlag], szFlag, g_MySQLConnections[0]);
			mysql_real_escape_string(PlayerInfo[extraid][pReferredBy], szReferredBy, g_MySQLConnections[0]);
			
			format(szQuery, sizeof(szQuery), "UPDATE players SET SMSLog = %d, TriageTime = %d, Married = %d, MarriedTo = '%s', Flag = '%s', ReferredBy = '%s', RefTokens = %d, RefTokensOffline = %d, Helper = %d, GangMod = %d, LiveBanned = %d, \
			FacMod = %d, PR = %d, DynMod = %d, DGA = %d, AP = %d, WHERE ID = %d",
			PlayerInfo[extraid][pSmslog], PlayerInfo[extraid][pTriageTime], PlayerInfo[extraid][pMarried], szMarriedTo, szFlag, szReferredBy, PlayerInfo[extraid][pRefTokens], PlayerInfo[extraid][pRefTokensOffline], PlayerInfo[extraid][pHelper],
			PlayerInfo[extraid][pGangMod], PlayerInfo[extraid][pLiveBanned], PlayerInfo[extraid][pFacMod], PlayerInfo[extraid][pPR], PlayerInfo[extraid][pDynMod], PlayerInfo[extraid][pDGA], PlayerInfo[extraid][pAP], PlayerInfo[extraid][pID]);
			
			mysql_query(szQuery, THREAD_SAVING_FINISHED, extraid, g_MySQLConnections[0]);
		}
Serverlogs:
Код:
[27/05/2016 21:20:54] [part] Dimitri_Stone has left the server (0:1)
[27/05/2016 21:20:54] errorid: 1064 | error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE ID = 1' at line 1 | callback: OnQueryFinish | query: UPDATE players SET SMSLog = 0, TriageTime = 0, Married = 0, MarriedTo = 'Nobody', Flag = '0', ReferredBy = '0', RefTokens = 0, RefTokensOffline = 0, Helper = 0, GangMod = 0, LiveBanned = 0, FacMod = 0, PR = 0, DynMod = 0, DGA = 0, AP = 0, WHERE ID = 1 | connection handle: 1 | resultid: 10 | extraid: 0
What did I do wrong ? I marked the things I have add blue
Reply
#2

Код:
.. DGA = %d, AP = %d, WHERE ID = %d
Remove the comma before WHERE clause.

Tip: You can also use mysql_format instead of format+mysql_real_escape_string.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)