Newbie to Mysql
#1

I tried to transform my Yini system to Mysql and i think i f****d up all.
This is the log: https://ufile.io/b438 .The version of the plugin/inc is R33, what is the problem? Thank you in advice
Reply
#2

- The logs show that you execute 2 INSERT queries when you only need 1.
- Set default values to columns so you won't have to insert values yourself.
- The number of count for specifiers do not match the arguments. It has 1 %e specifier but no argument found.
- Same problem as above for the UPDATE query (3 %d specifiers but no arguments).
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
- The logs show that you execute 2 INSERT queries when you only need 1.
Код:
 mysql_format(mysql, query, sizeof(query), "INSERT INTO `playerinfo` (`Name`, `Pass`, `Cash`, `AdminLevel`, `Kills`, `Deaths`, `Skin`, `Color`, `Level`, `RespectPoints`, `WantedLevel`, `Sex`, `Age`, `RegistredIP`, `Email`, `Muted`, `MuteTime`, `HouseID`, `ChangeSpawn`,  VALUES ('%e', '%e', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%e', '%e', 0, 0, 0, 0 )", playername, PlayerInfo[playerid][pPass], playerip );
                mysql_format(mysql, query2, sizeof(query2), "INSERT INTO `playerinfo` (`CarLic`, `BoatLic`, `PlaneLic`, `WeaponLic`, `Job`, `Warns`, `RentHouseID`, `FactionID`, `RobPoints`, `BankMoney`, `OreJucate`, `FactionRank`, `SecundeJucate`, `CarSlot1`, `CarSlot2`, `CarSlot3`, `CarSlot4`, `Premium`, `FactionPunish`, `WantedReason`, `JailTime`, `PremiumColor`,  VALUES (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)");
				mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
				mysql_tquery(mysql, query2, "OnAccountRegister", "i", playerid);
pawno don't let me make to long querys, i diden't split it proprietly?
Reply
#4

strcat
Reply
#5

Assuming that it did not give an error, you haven't used NOT NULL in the table's structure so in other words, it tries to insert 2 new records/accounts (the second will be bugged).

I'd split them with strcat and then format it. Removing grave accent character ` and setting default values as I mentioned earlier will reduce the query a lot.
pawn Код:
// WARNIG: The size of "query" should be long enough to fit the whole text

query = "INSERT INTO playerinfo ";
strcat(query, "(Name,Pass,Cash,AdminLevel,...)");
strcat(query, "VALUES ('%e','%e', ...)");

// you can split arguments as well
mysql_format(mysql, query, sizeof(query), query,
...,
...);

mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
Reply
#6

Quote:

query = "INSERT INTO `playerinfo` ";
strcat(query, "(`Name`, `Pass`, `Cash`, `AdminLevel`, `Kills`, `Deaths`, `Skin`, `Color`, `Level`, `RespectPoints`, `WantedLevel`, `Sex`, `Age`, `RegistredIP`, `Email`, `Muted`, `MuteTime`, `HouseID`, `ChangeSpawn`, `CarLic`, `BoatLic`, `PlaneLic`, `WeaponLic`, `Job`, `Warns`, `RentHouseID`, `FactionID`, `RobPoints`, `BankMoney`, `OreJucate`, `FactionRank`, `SecundeJucate`, `CarSlot1`, `CarSlot2`, `CarSlot3`, `CarSlot4`, `Premium`, `FactionPunish`, `WantedReason`, `JailTime`, `PremiumColor`) ");
strcat(query, "VALUES ('%e', '%e', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '%e', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');");

mysql_format(mysql, query, sizeof(query), query, playername,PlayerInfo[playerid][pPass],playerip);

mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);

... now what's the problem, it dosen't work
i'm noob
Код:
[00:06:40] [DEBUG] mysql_format - connection: 1, len: 700, format: "INSERT INTO `playerinfo` (`Name`, `Pass`, `Cash`, `AdminLevel`, `Kills`, `Deaths`, `Skin`, `Color`, `Level`, `RespectPoints`, `W..."
[00:06:40] [ERROR] mysql_format - destination size is too small
[00:06:40] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO `playerinfo` (`Name`, `Pass`, `Cash`, `AdminLevel`, ", callback: "OnAccountRegister", format: "i"
[00:06:40] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called
[00:06:40] [DEBUG] mysql_tquery - scheduling query "INSERT INTO `playerinfo` (`Name`, `Pass`, `Cash`, `AdminLevel`, `Kills`, `Deaths`, `Skin`, `Color`, `Level`, `RespectPoints`, `WantedLevel`, `Sex`, `Age`, `RegistredIP`, `Email`, `Muted`, `MuteTime`, `HouseID`, `ChangeSpawn`, `CarLic`, `BoatLic`, `PlaneLic`, `WeaponLic`, `Job`, `Warns`, `RentHouseID`, `FactionID`, `RobPoints`, `BankMoney`, `OreJucate`, `FactionRank`, `SecundeJucate`, `CarSlot1`, `CarSlot2`, `CarSlot3`, `CarSlot4`, `Premium`, `FactionPunish`, `WantedReason`, `JailTime`, `PremiumColor`) VALUE"..
[00:06:40] [DEBUG] CMySQLQuery::Execute[OnAccountRegister(i)] - starting query execution
[00:06:40] [ERROR] CMySQLQuery::Execute[OnAccountRegister(i)] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''' at line 1
[00:06:40] [DEBUG] CMySQLQuery::Execute[OnAccountRegister(i)] - error will be triggered in OnQueryError
[00:06:40] [DEBUG] CMySQLQuery::Execute[OnAccountRegister(i)] - data being passed to ProcessCallbacks()
[00:06:40] [DEBUG] Calling callback "OnQueryError"..
[00:06:40] [DEBUG] CMySQLQuery::~CMySQLQuery() - deconstructor called
// nevermind, query was too small
Reply
#7

Add more cells to your query variable to delete ERROR destination size is too small

new query[1024];
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)