It won't add
#1

Can someone tell me why this won't create org in DB??
PHP код:
CMD:createorg(playeridparams[])
{
    if(
PlayerInfo[playerid][Admin] < 5)
    {
        
ERROR(playerid"You are not allowed to use that command");
        return 
1;
    }
    new 
orgname[33], Float:XFloat:YFloat:ZFloat:iXFloat:iYFloat:iZ;
    if(
sscanf(params"s[33]fff"nameXYZ))
    {
        
USAGE(playerid"/createorg [Name] [X-int] [Y-int] [Z-int]");
        return 
1;
    }
    if(
strlen(name) < || 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(playeridiXiYiZ);
    
OrgInfo[org][oID] = org;
    
strmid(OrgInfo[org][oName], name0strlen(name), 255);
    
strmid(OrgInfo[org][oLeader], "Noone"0strlen("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_Orgsorg);
    
OrgLabel(org);
    new 
query[400];
    
mysql_format(g_SQLquerysizeof(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)",orgOrgInfo[org][oName], OrgInfo[org][oLeader], iXiYiZXYZOrgInfo[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_SQLquery);
    return 
1;

Any problems here??
Reply
#2

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)
Reply
#3

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!
Reply
#4

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.
Reply
#5

I've put query 600 still won't make it..
Reply
#6

Try making debugging the query string (print out the string) and check if the query is cut out.
Reply
#7

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)
Reply
#8

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.
Reply
#9

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??
Reply
#10

-FIXED-
I forgot to add ` xD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)