It won't add -
Micko123 - 17.11.2016
Can someone tell me why this won't create org in DB??
PHP код:
CMD:createorg(playerid, params[])
{
if(PlayerInfo[playerid][Admin] < 5)
{
ERROR(playerid, "You are not allowed to use that command");
return 1;
}
new org, name[33], Float:X, Float:Y, Float:Z, Float:iX, Float:iY, Float:iZ;
if(sscanf(params, "s[33]fff", name, X, Y, Z))
{
USAGE(playerid, "/createorg [Name] [X-int] [Y-int] [Z-int]");
return 1;
}
if(strlen(name) < 3 || strlen(name) > 22)
{
ERROR(playerid, "Org name can't be lower than 3 and higher than 22 chars");
return 1;
}
org = Iter_Free(i_Orgs);
GetPlayerPos(playerid, iX, iY, iZ);
OrgInfo[org][oID] = org;
strmid(OrgInfo[org][oName], name, 0, strlen(name), 255);
strmid(OrgInfo[org][oLeader], "Noone", 0, strlen("Noone"), 255);
OrgInfo[org][oExitX] = iX;
OrgInfo[org][oExitY] = iY;
OrgInfo[org][oExitZ] = iZ;
OrgInfo[org][oIntX] = X;
OrgInfo[org][oIntY] = Y;
OrgInfo[org][oIntZ] = Z;
OrgInfo[org][oSef] = 0;
OrgInfo[org][oMoney] = 0;
OrgInfo[org][oDrugs] = 0;
OrgInfo[org][oSefX] = 0;
OrgInfo[org][oSefY] = 0;
OrgInfo[org][oSefZ] = 0;
OrgInfo[org][oVW] = OrgInfo[org][oID] + 1;
OrgInfo[org][oInt] = OrgInfo[org][oID] + 1;
OrgInfo[org][orgExist] = true;
Iter_Add(i_Orgs, org);
OrgLabel(org);
new query[400];
mysql_format(g_SQL, query, sizeof(query),"INSERT INTO `orgs` (`ID`,`Name`,`Leader`,`ExitX`,`ExitY`,`ExitZ`,`IntX`,`IntY`,`IntZ`,`SefX`,`SefY,`SefZ`,`Sef`,`Money`,`Drugs`,`VW`,`Interior`)VALUES(%d,'%s','%s',%f,%f,%f,%f,%f,%f,%f,%f,%f,%d,%d,%d,%d,%d)",org, OrgInfo[org][oName], OrgInfo[org][oLeader], iX, iY, iZ, X, Y, Z, OrgInfo[org][oSefX], OrgInfo[org][oSefY], OrgInfo[org][oSefZ], OrgInfo[org][oSef], OrgInfo[org][oMoney], OrgInfo[org][oDrugs], OrgInfo[org][oID]+1,OrgInfo[org][oID]+1);
mysql_tquery(g_SQL, query);
return 1;
}
Any problems here??
Re: It won't add -
JaKe Elite - 17.11.2016
Instead of inserting a new row with some null values in it, You could simply create the table having these columns automatically filled out with null values - I am still not quite good at explaining how SQL works but yeah I hope you know what I mean

(Having some columns in null will make your job so much easier, I once had this problem and got tipped up about setting up the columns to null by default)
Re: It won't add -
Micko123 - 17.11.2016
You mean that I should make table and set default 0 in it??
But I still don't getit why it won't add.. It worked yesterday and now.. damn!
Re: It won't add -
JaKe Elite - 17.11.2016
Yes make the columns null (the one which isn't important when it comes to inserting a new row)
- The query string size isn't enough to handle the given query if i am not wrong.
Re: It won't add -
Micko123 - 17.11.2016
I've put query 600 still won't make it..
Re: It won't add -
JaKe Elite - 17.11.2016
Try making debugging the query string (print out the string) and check if the query is cut out.
Re: It won't add -
Micko123 - 17.11.2016
Nope.. Here is debuged
Код:
INSERT INTO `orgs` (`ID`,`Name`,`Leader`,`ExitX`,`ExitY`,`ExitZ`,`IntX`,`IntY`,`IntZ`,`SefX`,`SefY,`SefZ`,`Sef`,`Money`,`Drugs`,`VW`,`Interior`)VALUES(0,'ooo','Noone',1958.378296,1343.157227,15.374607,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0,0,1,1)
Re: It won't add -
BroZeus - 17.11.2016
Run the query directly in phpmyadmin to see what is the error or check mysql log in your server folder it should have the error regarding the query.
Re: It won't add -
Micko123 - 17.11.2016
I got this in log
Код:
[12:23:39] [ERROR] error #1064 while executing query "INSERT INTO `orgs` (`ID`,`Name`,`Leader`,`ExitX`,`ExitY`,`ExitZ`,`IntX`,`IntY`,`IntZ`,`SefX`,`SefY,`SefZ`,`Sef`,`Money`,`Drugs`,`VW`,`Interior`)VALUES(0,'ooo','Noone',1958.378296,1343.157227,15.374607,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0,0,1,1)": 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 'SefZ`,`Sef`,`Money`,`Drugs`,`VW`,`Interior`)VALUES(0,'ooo','Noone',1958.378296,1' at line 1 (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:6150)
Anyone can find proble??
Re: It won't add -
Micko123 - 17.11.2016
-FIXED-
I forgot to add
` xD