Invalid MySQL Syntax
#1

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.
Reply
#2

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.
Reply
#3

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


Forum Jump:


Users browsing this thread: 1 Guest(s)