MYSQL - input line too long (after substitutions)
#1

Well, I had my old project laying around and I wanted to change it to MYSQL instead of Y_Ini. However; got these errors.

Already tried using scatstr but it gave the error that UPDATE wasn't defined.

Код:
(665) : error 075: input line too long (after substitutions)
(666) : error 017: undefined symbol "pBanne"
(667) : warning 217: loose indentation
(667) : error 017: undefined symbol "dAdminName"
(667) : error 029: invalid expression, assumed zero
(667) : error 029: invalid expression, assumed zero
(667) : fatal error 107: too many error messages on one line
Код:
	new query[512]; // this is line 664
	mysql_format(mysql, query, sizeof(query), "UPDATE `users` SET `IP`=%s`Admin`=%d,`Money`=%d,`Level`=%d,`Kills`=%d,`Deaths`=%d,`Warns`=%d,`Banned`=%d,`BannedReason`=%s,`BannedBy`=%s,`Beta`=%d,`Faction`=%d,`FactionRank`=%s,`FactionRight`=%d, WHERE `ID`=%d",\
	IP[playerid], PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pScores], PlayerInfo[playerid][pKills],PlayerInfo[playerid][pDeaths],PlayerInfo[playerid][pWarns],PlayerInfo[playerid][pBanned],PlayerInfo[playerid][pBanReason],PlayerInfo[playerid][pBannedAdminName],PlayerInfo[playerid][pBeta],PlayerInfo[playerid][pFaction], PlayerInfo[playerid][pFactionRank],PlayerInfo[playerid][pFactionRight], PlayerInfo[playerid][ID]);

	mysql_tquery(mysql, query, "", "");
Reply
#2

The input in the format is too much long, and so also the others error are due to this problem. To fix this, you can use strins or alternatively you can do two different queries to split the other one..
Reply
#3

Quote:
Originally Posted by ReshiramZekrom
Посмотреть сообщение
The input in the format is too much long, and so also the others error are due to this problem. To fix this, you can use strins or alternatively you can do two different queries to split the other one..
Could you tell me what strins are?

Also about the two different queries; would it decrease performance?
Reply
#4

Quote:
Originally Posted by ThaCrypte
Посмотреть сообщение
Also about the two different queries; would it decrease performance?
It shouldn't really decrease performance either way (if you've done it properly). Your question actually depends on many different factors (player base, amount of queries going on etc). For me, I have chat logging, command logs, attempted breaches, attempted advertising and instant updates for everything (i.e. when someone uses /pay the db is updated right there and then) and I have no performance issues whatsoever. You've just got to make sure you've done it properly, use a good enough host, and it should be perfectly fine.
Reply
#5

Quote:
Originally Posted by ThaCrypte
Посмотреть сообщение
Could you tell me what strins are?

Also about the two different queries; would it decrease performance?
https://sampwiki.blast.hk/wiki/Strins

Try in this way:

pawn Код:
new string[512];

    strins(string,"UPDATE `users` SET `IP`=%s`Admin`=%d,`Money`=%d,`Level`=%d,`Kills`=%d,`Deaths`=%d,`Warns`=%d,`Banned`=%d,`BannedReason`=%s,`BannedBy`=%s,",strlen(string));
    strins(string,"`Beta`=%d,`Faction`=%d,`FactionRank`=%s,`FactionRight`=%d, WHERE `ID`=%d",strlen(string));
    new query[512]; // this is line 664
    format(query, sizeof(query), string, IP[playerid], PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pScores], PlayerInfo[playerid][pKills],PlayerInfo[playerid][pDeaths],PlayerInfo[playerid][pWarns],PlayerInfo[playerid][pBanned],PlayerInfo[playerid][pBanReason],PlayerInfo[playerid][pBannedAdminName],PlayerInfo[playerid][pBeta],PlayerInfo[playerid][pFaction], PlayerInfo[playerid][pFactionRank],PlayerInfo[playerid][pFactionRight], PlayerInfo[playerid][ID]);

    mysql_query(query);
If you use more queries it creates more lag because the server must search the ID of the player twice, but it's not very influent
Reply
#6

Quote:
Originally Posted by ReshiramZekrom
Посмотреть сообщение
https://sampwiki.blast.hk/wiki/Strins

Try in this way:

pawn Код:
new string[512];

    strins(string,"UPDATE `users` SET `IP`=%s`Admin`=%d,`Money`=%d,`Level`=%d,`Kills`=%d,`Deaths`=%d,`Warns`=%d,`Banned`=%d,`BannedReason`=%s,`BannedBy`=%s,",strlen(string));
    strins(string,"`Beta`=%d,`Faction`=%d,`FactionRank`=%s,`FactionRight`=%d, WHERE `ID`=%d",strlen(string));
    new query[512]; // this is line 664
    format(query, sizeof(query), string, IP[playerid], PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pScores], PlayerInfo[playerid][pKills],PlayerInfo[playerid][pDeaths],PlayerInfo[playerid][pWarns],PlayerInfo[playerid][pBanned],PlayerInfo[playerid][pBanReason],PlayerInfo[playerid][pBannedAdminName],PlayerInfo[playerid][pBeta],PlayerInfo[playerid][pFaction], PlayerInfo[playerid][pFactionRank],PlayerInfo[playerid][pFactionRight], PlayerInfo[playerid][ID]);

    mysql_query(query);
If you use more queries it creates more lag because the server must search the ID of the player twice, but it's not very influent
Seems like this fixed it, but received many other errors, if I can't get those fixed I'll add them to this thread :P

EDIT:
Код:
// (671) : error 035: argument type mismatch (argument 1)
	mysql_query(query);
Reply
#7

Try use
new p = playerid;
and replace all [playerid] to [p]
Reply
#8

Fixed I guess, gonna test it out now.
Reply
#9

pawn Код:
mysql_tquery(mysql, query, "", "");
Reply
#10

I encountered another problem. My hashed password doesn't seem to save.

at register dialogue I have:

PHP код:
WP_Hash(passsizeof(pass), inputtext);
                
mysql_format(mysqlquerysizeof(query), "INSERT INTO `users` (`Username`, `Password`, `IP`, `Admin`, `Money`, `Level`, `Kills`, `Deaths`, `Warns`, `Banned`, `BanReason`, `BannedBy`, `Beta`, `Faction`, `FactionRank`, `FactionRight`) VALUES ('%e', '%s', '%s', 0, 0, 1, 0, 0, 0, 0, '%s', '%s', 0, -1, '%s', -1)"Name[playerid], passIP[playerid], Empty, Empty, Empty);
                
mysql_tquery(mysqlquery"OnAccountRegister""i"playerid); 
and at login I have

PHP код:
                new hpass[129];
                
WP_Hash(hpass129inputtext);
                if(!
strcmp(hpassPlayerInfo[playerid][pPass]))
                {
                    new 
query[100];
                    
mysql_format(mysqlquerysizeof(query), "SELECT * FROM `users` WHERE `Username` = '%e' LIMIT 1"Name[playerid]);
                    
mysql_tquery(mysqlquery"OnAccountLoad""i"playerid);
                    
PassWordSecure[playerid] = 1;
                } 
Also, when I register a lot of stuff get's set to 0 by default. But when I log in; it's normal again.

Mysql log:

Код:
[23:16:37] [DEBUG] mysql_connect - host: "localhost", user: "root", database: "Database_DRP", password: "****", port: 3306, autoreconnect: true, pool_size: 2
[23:16:37] [DEBUG] CMySQLHandle::Create - creating new connection..
[23:16:37] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called
[23:16:37] [DEBUG] CMySQLHandle::Create - connection created (id: 1)
[23:16:37] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[23:16:37] [DEBUG] CMySQLConnection::Connect - connection was successful
[23:16:37] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[23:16:37] [DEBUG] mysql_errno - connection: 1
[23:16:37] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[23:16:37] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[23:16:37] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[23:16:37] [DEBUG] CMySQLConnection::Connect - connection was successful
[23:16:37] [DEBUG] CMySQLConnection::Connect - connection was successful
[23:16:37] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[23:16:37] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[23:16:37] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[23:17:13] [DEBUG] mysql_format - connection: 1, len: 512, format: "SELECT `Password`, `ID` FROM `users` WHERE `Username` = '%e' LIMIT 1"
[23:17:13] [DEBUG] mysql_tquery - connection: 1, query: "SELECT `Password`, `ID` FROM `users` WHERE `Username` = 'Yo_Momm", callback: "OnAccountCheck", format: "i"
[23:17:13] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - starting query execution
[23:17:13] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - query was successfully executed within 0.280 milliseconds
[23:17:13] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[23:17:13] [DEBUG] Calling callback "OnAccountCheck"..
[23:17:13] [DEBUG] cache_get_data - connection: 1
[23:17:13] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[23:17:18] [DEBUG] mysql_format - connection: 1, len: 300, format: "INSERT INTO `users` (`Username`, `Password`, `IP`, `Admin`, `Money`, `Level`, `Kills`, `Deaths`, `Warns`, `Banned`, `BanReason`,..."
[23:17:18] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO `users` (`Username`, `Password`, `IP`, `Admin`, `Mon", callback: "OnAccountRegister", format: "i"
[23:17:18] [DEBUG] CMySQLQuery::Execute[OnAccountRegister] - starting query execution
[23:17:18] [DEBUG] CMySQLQuery::Execute[OnAccountRegister] - query was successfully executed within 118.86 milliseconds
[23:17:18] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[23:17:18] [DEBUG] Calling callback "OnAccountRegister"..
[23:17:18] [DEBUG] cache_insert_id - connection: 1
[23:17:18] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[23:17:21] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `users` SET `IP`=127.0.0.1 `Admin`=0, `Money`=0, `Level`=", callback: "(null)", format: "(null)"
[23:17:21] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[23:17:21] [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 '.0.1 `Admin`=0, `Money`=0, `Level`=0, `Kills`=0, `Deaths`=0, `Warns`=0, `Banned`' at line 1
[23:17:21] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError
[23:17:48] [DEBUG] mysql_format - connection: 1, len: 512, format: "SELECT `Password`, `ID` FROM `users` WHERE `Username` = '%e' LIMIT 1"
[23:17:48] [DEBUG] mysql_tquery - connection: 1, query: "SELECT `Password`, `ID` FROM `users` WHERE `Username` = 'Yo_Momm", callback: "OnAccountCheck", format: "i"
[23:17:48] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - starting query execution
[23:17:48] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - query was successfully executed within 0.251 milliseconds
[23:17:48] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[23:17:48] [DEBUG] Calling callback "OnAccountCheck"..
[23:17:48] [DEBUG] cache_get_data - connection: 1
[23:17:48] [DEBUG] cache_get_field_content - row: 0, field_name: "Password", connection: 129, max_len: 1
[23:17:48] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Password", data: ""
[23:17:48] [DEBUG] cache_get_field_content_int - row: 0, field_name: "ID", connection: 1
[23:17:48] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "ID", data: "11"
[23:17:48] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[23:28:19] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `users` SET `IP`=127.0.0.1 `Admin`=-1, `Money`=-1, `Level", callback: "(null)", format: "(null)"
[23:28:19] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[23:28:19] [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 '.0.1 `Admin`=-1, `Money`=-1, `Level`=-1, `Kills`=-1, `Deaths`=-1, `Warns`=-1, `B' at line 1
[23:28:19] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)