SA-MP Forums Archive
Mysql problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Mysql problem (/showthread.php?tid=608890)



Mysql problem - Welaurs - 06.06.2016

Hi all. I have a problem. I have
PHP код:
stock SavePlayerData(playerid

    new 
sqlSaveString[2048]; 
    
mysql_format(handlesqlSaveString2048"UPDATE (`Inviter`, `Name`, `Password`, `Sex`, `Skin`) SET ('%s', '%s', '%s', %d, %d)"PI[playerid][pInviter], GetName(playerid), PI[playerid][pPassword], PI[playerid][pSex], PI[playerid][pSkin]); 
    
mysql_tquery(handlesqlSaveString""""); 
    return 
1

and I have error
PHP код:
[09:57:51] [DEBUGmysql_format connection1len2048format"UPDATE (`Inviter`, `Name`, `Password`, `Sex`, `Skin`) SET ('%s', '%s', '%s', %d, %d)" 
[09:57:51] [DEBUGmysql_tquery connection1query"UPDATE (`Inviter`, `Name`, `Password`, `Sex`, `Skin`) SET ('', '"callback"(null)"format"(null)" 
[09:57:51] [DEBUGCMySQLQuery::Execute[] - starting query execution 
[09:57:51] [ERRORCMySQLQuery::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 '('', '', '', 0, 15)' at line 1 
[09:57:51] [DEBUGCMySQLQuery::Execute[] - error will be triggered in OnQueryError 



Re: Mysql problem - dusk - 06.06.2016

That's nt how UPDATE queries work.

pawn Код:
mysql_format(handle, sqlSaveString, 2048, "UPDATE table_name SET `Inviter` = '%s', `Name` = '%s', Password = '%s', Sex = %d, Skin = %d", PI[playerid][pInviter], GetName(playerid), PI[playerid][pPassword], PI[playerid][pSex], PI[playerid][pSkin]);  
    mysql_tquery(handle, sqlSaveString, "", "");
Change the 'table_name' to your table name. Also as there is no WHERE clause it will set these values for ALL rows and I'm quite sure that's not what you want.