PDA

View Full Version : Invalid MySQL Syntax


Corello2010
17/01/2012, 09:28 PM
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:


format(mainstring,sizeof(mainstring),"UPDATE `players` SET `Admin`=%d,`Human`=%d,`Member`=%d,`Rank`=%d,`First Reg`=%d,`Infected`=%d,`Skin`=%d,`Gold`=%d,`Rep`=%d ,`Level`=%d,`Minutes`=%d,`HumanSkill`=%d,`ZombieSk ill`=%d,`Mechanic`=%d,`Aim`=%d,`Luck`=%d,`HumanKil ls`=%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:

[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.

Sinner
17/01/2012, 09:45 PM
At the end of your query:

`Callsign`=%s, WHERE `Username` = %s",

Should be:

`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.

Vince
17/01/2012, 10:23 PM
Strings need to be wrapped in single quotes at all times.