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



help (mysql) - JeaSon - 06.12.2014

i got this error when i try to register
PHP код:
[22:52:40] [DEBUGCMySQLQuery::Execute[OnAccountRegister] - starting query execution
[22:52:40] [ERRORCMySQLQuery::Execute[OnAccountRegister] - (error #1064) Erreur de syntaxe prиs de 'VALUES ('INSERT INTO `players` (`Username`, `Password`, `IP`, `Admin`, `Score`, ' а la ligne 1
[22:52:40] [DEBUGCMySQLQuery::Execute[OnAccountRegister] - error will be triggered in OnQueryError 
this is inserting query
pawn Код:
new query[3000];
            mysql_format(mysql, query, sizeof(query),"INSERT INTO `players` (`Username`, `Password`, `IP`, `Admin`, `Score`, `Kills`, `Deaths`, `Cookie`, `Notify` ,`TotalTime`,`SkinID`");
            mysql_format(mysql, query, sizeof(query),"%s`AccountLocked`, `AccountBanned`, `BanningAdmin`, `BannedReason`, `MoneyBank`,`Health`, `Armour`, `LastActivity`", query);
            mysql_format(mysql, query, sizeof(query),"%s`WeaponSlot1`, `WepSlotAmmo1`, `WeaponSlot2`, `WepSlotAmmo2`, `WeaponSlot3`, `WepSlotAmmo3`, `WeaponSlot4`, `WepSlotAmmo4`, `WeaponSlot5`, `WepSlotAmmo5`, `Money` ", query);
            mysql_format(mysql, query, sizeof(query),"VALUES ('%e', '%s', '%s', 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 99.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,)",query, Name[playerid], pInfo[playerid][Password], IP[playerid]);
            mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);



Re: help (mysql) - Ryz - 06.12.2014

are you sure you made all tables correctly in mysql server? cuz codes looks complete


Re: help (mysql) - CoaPsyFactor - 06.12.2014

Ryz, it's clear that you haven't read query :P

pawn Код:
new query[3000];
            mysql_format(mysql, query, sizeof(query),"INSERT INTO `players` (`Username`, `Password`, `IP`, `Admin`, `Score`, `Kills`, `Deaths`, `Cookie`, `Notify` ,`TotalTime`,`SkinID`");
            mysql_format(mysql, query, sizeof(query),"%s`AccountLocked`, `AccountBanned`, `BanningAdmin`, `BannedReason`, `MoneyBank`,`Health`, `Armour`, `LastActivity`", query);
            mysql_format(mysql, query, sizeof(query),"%s`WeaponSlot1`, `WepSlotAmmo1`, `WeaponSlot2`, `WepSlotAmmo2`, `WeaponSlot3`, `WepSlotAmmo3`, `WeaponSlot4`, `WepSlotAmmo4`, `WeaponSlot5`, `WepSlotAmmo5`, `Money`) ", query);
            mysql_format(mysql, query, sizeof(query),"VALUES ('%e', '%s', '%s', 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 99.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,)",query, Name[playerid], pInfo[playerid][Password], IP[playerid]);
            mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
this should do


Re: help (mysql) - BroZeus - 06.12.2014

like this -
pawn Код:
new query[1000];
format(query,sizeof(query),""):
strcat(query,"INSERT INTO `players` (`Username`, `Password`, `IP`, `Admin`, `Score`, `Kills`, `Deaths`, `Cookie`, `Notify` ,`TotalTime`,`SkinID`");
strcat(query,"`AccountLocked`, `AccountBanned`, `BanningAdmin`, `BannedReason`, `MoneyBank`,`Health`, `Armour`, `LastActivity`");
strcat(query,"`WeaponSlot1`, `WepSlotAmmo1`, `WeaponSlot2`, `WepSlotAmmo2`, `WeaponSlot3`, `WepSlotAmmo3`, `WeaponSlot4`, `WepSlotAmmo4`, `WeaponSlot5`, `WepSlotAmmo5`, `Money`) ");
strcat(query,"VALUES ('%e', '%s', '%s', 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 99.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,)");
mysql_format(mysql, query,sizeof(query),query,Name[playerid], pInfo[playerid][Password], IP[playerid]);
mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
also see this http://forum.sa-mp.com/showpost.php?...18&postcount=6


Re: help (mysql) - Vince - 06.12.2014

Dude, use default values in your tables. You're only inserting 3 actual variables, the rest are constants. Also read my tutorial on how to properly store weapon data in MySQL. Columns that have numbers in them should (in most cases) be moved to a separate table.


Re: help (mysql) - Ryz - 06.12.2014

Quote:
Originally Posted by CoaPsyFactor
Посмотреть сообщение
Ryz, it's clear that you haven't read query :P
too fast_ fail fast -_- .ty 4 pointing


Re: help (mysql) - CoaPsyFactor - 06.12.2014

np, I had soooo many times that fail happened , and after that I started reading char by char if I don't see any logical problem