SA-MP Forums Archive
Invalid MySQL Syntax - 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: Invalid MySQL Syntax (/showthread.php?tid=311691)



Invalid MySQL Syntax - Corello2010 - 17.01.2012

Alright, basically put I've been scripting again recently and my coding seems to have turned to wank because I can no longer get this working:

pawn Код:
format(mainstring,sizeof(mainstring),"UPDATE `players` SET `Admin`=%d,`Human`=%d,`Member`=%d,`Rank`=%d,`FirstReg`=%d,`Infected`=%d,`Skin`=%d,`Gold`=%d,`Rep`=%d,`Level`=%d,`Minutes`=%d,`HumanSkill`=%d,`ZombieSkill`=%d,`Mechanic`=%d,`Aim`=%d,`Luck`=%d,`HumanKills`=%d,`ZombieKills`=%d,`Infects`=%d,`HasRadio`=%d,`RadioFreq`=%d,`Callsign`=%s, WHERE `Username` = %s",
        PlayerInfo[playerid][pAdmin],
        PlayerInfo[playerid][pHuman],
        PlayerInfo[playerid][pMember],
        PlayerInfo[playerid][pRank],
        PlayerInfo[playerid][pFirstReg],
        PlayerInfo[playerid][pInfected],
        PlayerInfo[playerid][pSkin],
        PlayerInfo[playerid][pGold],
        PlayerInfo[playerid][pRep],
        PlayerInfo[playerid][pLevel],
        PlayerInfo[playerid][pMinutesOnline],
        PlayerInfo[playerid][pHumanSkill],
        PlayerInfo[playerid][pZombieSkill],
        PlayerInfo[playerid][pMechanic],
        PlayerInfo[playerid][pAim],
        PlayerInfo[playerid][pLuck],
        PlayerInfo[playerid][pHumanKills],
        PlayerInfo[playerid][pZombKills],
        PlayerInfo[playerid][pInfects],
        PlayerInfo[playerid][pHasRadio],
        PlayerInfo[playerid][pRadioFreq],
        PlayerInfo[playerid][pCallSign],
        GetName(playerid));
        mysql_query(mainstring);
I just get my MySQL log spammed with:

Quote:

[15:25:07] CMySQLHandler::Query(UPDATE `players` SET `Admin`=1,`Human`=1,`Member`=1,`Rank`=1,`FirstReg` =0,`Infected`=1,`Skin`=1,`Gold`=1,`Rep`=1,`Level`= 1,`Minutes`=1,`HumanSkill`=1,`ZombieSkill`=1,`Mech anic`=1,`Aim`=1,`Luck`=1,`HumanKills`=1,`ZombieKil ls`=1,`Infects`=1,`HasRadio`=1,`RadioFreq`=1,`Call sign`=, WHERE `Username` = Mike_Corello) - An error has occured. (Error ID: 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 ' WHERE `Username` = Mike_Corello' at line 1)

I'm using Blue's MySQL plugin. And basically, like it if any of you can help? Thanks.


Re: Invalid MySQL Syntax - Sinner - 17.01.2012

At the end of your query:

pawn Код:
`Callsign`=%s, WHERE `Username` = %s",
Should be:

pawn Код:
`Callsign`=%s WHERE `Username` = %s",
You probably forgot to remove the ,
Maybe there are other syntax errors, but that one will stop the query from functioning.


Re: Invalid MySQL Syntax - Vince - 17.01.2012

Strings need to be wrapped in single quotes at all times.