SA-MP Forums Archive
MYSQL DON'T WORK - 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 DON'T WORK (/showthread.php?tid=589422)



MYSQL DON'T WORK - MasonSFW - 19.09.2015

IT'S CORRECT CODE?

Function OnAccountRegister isn't call



Re: MYSQL DON'T WORK - Alpay0098 - 19.09.2015

Seems ok but you can increase array size if query[300];
What's the problem?


Re: MYSQL DON'T WORK - MasonSFW - 19.09.2015

It doesn't insert to data base


Re: MYSQL DON'T WORK - MasonSFW - 19.09.2015

Bump


Re: MYSQL DON'T WORK - BroZeus - 19.09.2015

The Code seems ok to me, enable MySQL logging by putting 'mysql_log(LOG_ALL);' in OnGameModeInit before you connect to the db then try running the query and check MySQL log file in server directory it will show you what is the error. Make sure that the MySQL server is up and running.
Form your code I would like to give you some tips :


Re: MYSQL DON'T WORK - MasonSFW - 19.09.2015

Please example to me
This is error log
Код:
[14:56:52] [DEBUG] mysql_connect - host: "localhost", user: "root", database: "server_database", password: "****", port: 3306, autoreconnect: true
[14:56:52] [DEBUG] CMySQLHandle::Create - creating new connection..
[14:56:52] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called
[14:56:52] [DEBUG] CMySQLHandle::Create - connection created with ID = 1
[14:56:52] [DEBUG] CMySQLConnection::Connect - connection was successful
[14:56:52] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[14:56:52] [DEBUG] CMySQLConnection::Connect - connection was successful
[14:56:52] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[14:56:52] [DEBUG] mysql_errno - connection: 1
[14:57:17] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT `pPassword`, `pID` FROM `playeraccounts` WHERE `Username` = '%e' LIMIT 1"
[14:57:17] [DEBUG] mysql_tquery - connection: 1, query: "SELECT `pPassword`, `pID` FROM `playeraccounts` WHERE `Username`", callback: "OnAccountCheck", format: "i"
[14:57:17] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called
[14:57:17] [DEBUG] mysql_tquery - scheduling query "SELECT `pPassword`, `pID` FROM `playeraccounts` WHERE `Username` = 'Daves' LIMIT 1"..
[14:57:17] [DEBUG] CMySQLQuery::Execute[OnAccountCheck(i)] - starting query execution
[14:57:17] [DEBUG] CMySQLQuery::Execute[OnAccountCheck(i)] - query was successful
[14:57:17] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[14:57:17] [DEBUG] CMySQLQuery::Execute[OnAccountCheck(i)] - data being passed to ProcessCallbacks()
[14:57:17] [DEBUG] Calling callback "OnAccountCheck"..
[14:57:17] [DEBUG] cache_get_data - connection: 1
[14:57:17] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[14:57:17] [DEBUG] CMySQLQuery::~CMySQLQuery() - deconstructor called
[14:57:19] [DEBUG] mysql_format - connection: 1, len: 1000, format: ""INSERT INTO `playeraccounts` (`Username`, `pPassword`, `pCash`, `pMoney`, `pAdmin`, `pKills`, `pTeamFaction`, `pStaff`,`pSaveSk..."
[14:57:19] [DEBUG] mysql_tquery - connection: 1, query: ""INSERT INTO `playeraccounts` (`Username`, `pPassword`, `pCash`,", callback: "OnRegistered", format: "i"
[14:57:19] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called
[14:57:19] [DEBUG] mysql_tquery - scheduling query ""INSERT INTO `playeraccounts` (`Username`, `pPassword`, `pCash`, `pMoney`, `pAdmin`, `pKills`, `pTeamFaction`, `pStaff`,`pSaveSkin`, `pSelected`, `pCharater`, `pLoggedIn`, `pSpy`, `pFbi`, `pFaction`, `pQuit`,`pDeathRP`, `pSpawnPosX`, `pSpawnPosY`, `pSpawnPosZ`, `pSpawnSaved`, `pArmour`,`pHostAddress`, `pLastPlayed`, `pIP`, `pAmmo1`, `pAmmo2`, `pSpyRank`) VALUES ('Daves', '12345', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'None', 0, '127.0.0.1', 0, 0, 'None')""..
[14:57:19] [DEBUG] CMySQLQuery::Execute[OnRegistered(i)] - starting query execution
[14:57:19] [ERROR] CMySQLQuery::Execute[OnRegistered(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 '"INSERT INTO `playeraccounts` (`Username`, `pPassword`, `pCash`, `pMoney`, `pAdm' at line 1
[14:57:19] [DEBUG] CMySQLQuery::Execute[OnRegistered(i)] - error will be triggered in OnQueryError
[14:57:19] [DEBUG] CMySQLQuery::Execute[OnRegistered(i)] - data being passed to ProcessCallbacks()
[14:57:19] [DEBUG] Calling callback "OnQueryError"..
[14:57:19] [DEBUG] CMySQLQuery::~CMySQLQuery() - deconstructor called
[14:57:22] [DEBUG] mysql_format - connection: 1, len: 1000, format: "UPDATE `playeraccounts` SET `pPassword`, `pIP`, `pAdmin`, `pKills`, `pMoney`,`pCash` ,`pTeamFaction`, `pStaff`, `pSaveSkin`, `pS..."
[14:57:22] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `playeraccounts` SET `pPassword`, `pIP`, `pAdmin`, `pKill", callback: "(null)", format: "(null)"
[14:57:22] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called
[14:57:22] [DEBUG] mysql_tquery - scheduling query "UPDATE `playeraccounts` SET `pPassword`, `pIP`, `pAdmin`, `pKills`, `pMoney`,`pCash` ,`pTeamFaction`, `pStaff`, `pSaveSkin`, `pSelected`, `pCharater`, `pLoggedIn`, `pSpy`,`pFbi`, `pFaction`, `pQuit`, `pDeathRP`, `pSpawnPosX`, `pSpawnPosY`, `pSpawnPosZ`, `pSpawnSaved`, `pArmour`,`pHostAddress`, `pLastPlayed`, `pAmmo1`, `pAmmo2` WHERE `ID`=80"..
[14:57:22] [DEBUG] CMySQLQuery::Execute[()] - starting query execution
[14:57:22] [ERROR] CMySQLQuery::Execute[()] - (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 ' `pIP`, `pAdmin`, `pKills`, `pMoney`,`pCash` ,`pTeamFaction`, `pStaff`, `pSaveSk' at line 1
[14:57:22] [DEBUG] CMySQLQuery::Execute[()] - error will be triggered in OnQueryError
[14:57:22] [DEBUG] CMySQLQuery::Execute[()] - data being passed to ProcessCallbacks()
[14:57:22] [DEBUG] Calling callback "OnQueryError"..
[14:57:22] [DEBUG] CMySQLQuery::~CMySQLQuery() - deconstructor called



Re: MYSQL DON'T WORK - BroZeus - 19.09.2015

Ok so after checking length of query i found that it was 479 more than current query holding var size which is 300.
Either follow the things I told you in previous reply to reduce the query size(recommended) or increase the query variable size to 500(not recommended).
If you didn't understand what I told in the last reply then tell me i'll try to explain in more details.


Re: MYSQL DON'T WORK - MasonSFW - 19.09.2015

this ?




Re: MYSQL DON'T WORK - BroZeus - 19.09.2015

You need to do new string[500], query[500]; to solve the problem
But as I told try to make query as small as possible, set the fields such as cash,admin..etc to 0 and then insert only name and IP. You don't need to insert all the fields at once!