SA-MP Forums Archive
SQL syntax error - 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: SQL syntax error (/showthread.php?tid=346334)



SQL syntax error - iGetty - 28.05.2012

pawn Код:
format(Query,sizeof(Query),"INSERT INTO `Accounts` (Username,Password,IP,Money,Level,AdminLevel,Faction,FactionRank,RegistrationStep,BirthDay,BirthMonth,BirthYear,SpawnPoint,TutorialComplete,HelperLevel,Accent,MinutesPlayed,AchievementPoints,ExperiencePoints,DonatorLevel,Deaths,Kills,Clothes1,Clothes2,Clothes3,ClothesUsed,CarLicense,HouseKey), VALUES('%s','%s','%s','500','1','0','0','0','0','0','0','0','0','0','0','None','0','0','0','0','0','0','0','0','0','0','0','0')",
                pName(playerid),inputtext,GetIP(playerid));
                mysql_query(Query);
                mysql_store_result();
                mysql_free_result();
                format(Query,sizeof(Query),"INSERT INTO `Accounts` (Business1Key,Business2Key), VALUES('0','0')");
                mysql_query(Query);
                mysql_store_result();
                mysql_free_result();

It doesn't work, it shows "
Код:
[08:27:57] 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 ' VALUES('0','0')' at line 1 -1 -1 NULL INSERT INTO `Accounts` (Business1Key,Business2Key), VALUES('0','0') 1
[08:27:57] 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 ' VALUES('Danny_Kovalchuk','lolnoob','75.118.152.108','500','1','0','0','0','0','' at line 1 -1 -1 NULL INSERT INTO `Accounts` (Username,Password,IP,Money,Level,AdminLevel,Faction,FactionRank,RegistrationStep,BirthDay,BirthMonth,BirthYear,SpawnPoint,TutorialComplete,HelperLevel,Accent,MinutesPlayed,AchievementPoints,ExperiencePoints,DonatorLevel,Deaths,Kills,Clothes1,Clothes2,Clothes3,ClothesUsed,CarLicense,HouseKey), VALUES('Danny_Kovalchuk','password','127.0.0.1','500','1','0','0','0','0','0','0','0','0','0','0','None','0','0','0','0','0','0','0','0','0','0','0','0') 1
How can I change it?


Re: SQL syntax error - Laronic - 28.05.2012

Remove the comma before "VALUES" in both queries
INSERT INTO `Accounts` (Business1Key,Business2Key), VALUES('0','0')

Edit: Remove the store & free result for those queries


Re: SQL syntax error - iGetty - 28.05.2012

Now it creates two accounts.

One is "My_Name" the next is a blank name.


Re: SQL syntax error - dannyk0ed - 28.05.2012

Thanks for putting my name here.


Re: SQL syntax error - iGetty - 28.05.2012

Quote:
Originally Posted by dannyk0ed
Посмотреть сообщение
Thanks for putting my name here.
Welcome, thanks for the off-topic. :P