SA-MP Forums Archive
mysql - 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 (/showthread.php?tid=560210)



mysql - xStunt - 27.01.2015

where the error?

Код:
gsString[ 0 ] = EOS;
format( gsString, 2048, "INSERT INTO `Accounts`(`Key`, `Name`, `IP`, `Password`, `RegisterDate`, `LoggedIn`, `Level`, `Vip`, `rVip`, `LastOn`, \
`Cash`, `Score`, `Kills`, `Deaths`, `Online`, `Rank`, `BestKillings`, `TimesOnServer`," );
format( gsString, 2048, "%s`FavSkin`, `UseSkin`,`Positive`, `Negative`, \
`Clan`, `ClanRank`, `ClanPoints`, `ClanDeaths`, `ClanOnline`, `ClanJoined`, `Kicks`, `Bans`, `Jails`,", gsString );
format( gsString, 2048, "%s`Warns`, `ClearChats`, `ReactionTest`, `MathTest`, `Mutes`, `ARatio`, `Property`, `Jailed`, `JailTime`, `Frozen`, \
`FreezeTime`, `ChatColor`, `RaceScore`, `DriftScore`, `DuelScore`, `vSpawn_X`, `vSpawn_Y`, `vSpawn_Z`, `vSpawn_A`, \
`TopOnline`, `AdminWarns`, `OwnedCarID`, `AllowToken`, `Token`, `VIPTime`, `SavingSts`, `HouseID`, `BankMoney`,`FreeVIP`", gsString );
format( gsString, 2048, "%s VALUES (0, '%s', '%s', '%s', '%d-%d-%d', 1, 0, 0, 0, '%d-%d-%d', \
20000, 0, 0, 0, '00:00:00', 0, 0, 1, \
0, 0, 0, 0,", gsString, PlayerName( playerid ), GetPlayerIPEx( playerid ), Buf, liYear, liMonth, liDay, liYear, liMonth, liDay );
format( gsString, 2048, "%s'None', 0, 0, 0, '00:00:00', 'None', 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0, '00:00', 0, \
'00:00', '0xFFFFFFFF', 0, 0, 0, 0.00, 0.00, 0.00, 0.00, \
0, 0, 0, 0, 0, 0, '0,0', 0, 0, 1)", gsString);
mysql_function_query( g_Handle, gsString, false, "OnAccountCreated", "i", playerid );
Код:
[18:02:23] [ERROR] CMySQLQuery::Execute[OnAccountCreated(i)] - (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 'VALUES (0, 'tester', '212.8.167.150', 'FBF59A5DC49F8206277D0C57C1E6F0B25D0F71958' at line 1



Re: mysql - PowerPC603 - 27.01.2015

That query can be made ALOT shorter if you just set all columns to have a default value of 0 where needed.
Like Kills, Deaths, Score, Cash, AdminWarns, DriftScore, VIPTime, ...

Then you only need to create a short query where you add the playername, password, IP and such, and MySQL will automatically fill in the default values for columns that have a default value.

Your query can be reduced to one single line that way and will be alot easier to spot any bugs.