SA-MP Forums Archive
SQL (error #1064) - 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: SQL (error #1064) (/showthread.php?tid=582575)



SQL (error #1064) - Beckett - 21.07.2015

Been double-checking this for a while, can't figure out what's wrong in this query. Can anyone check it out and tell me what's wrong?


pawn Код:
format(query,sizeof(query),"INSERT INTO texts (ID,distance,x,y,z,xx,yy,zz,text,vw,int,vww,intt) VALUES (%i,%i,%f,%f,%f,%f,%f,%f,'%s',%i,%i,%i,%i)",
        id,T[id][dDistance],T[id][tX],T[id][tY],T[id][tZ],T[id][tXx],T[id][tYy],T[id][tZz],T[id][xText],T[id][xVW],T[id][xInt],T[id][xVWw],T[id][xIntt]);
        mysql_tquery(mysql,query,"testtest");
Output:
pawn Код:
INSERT INTO texts (ID,distance,x,y,z,xx,yy,zz,text,vw,int,vww,intt) VALUES (1,50,1555.216796,-1726.411987,13.546875,0.000000,0.000000,0.000000,'Test',0,0,0,0)
Error:
pawn Код:
[20:32:25] [ERROR] CMySQLQuery::Execute[testtest] - (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 'int,vww,intt) VALUES (1,10,1559.668945,-1727.496459,13.382812,0.000000,0.000000,' at line 1
Thanks.


Re: SQL (error #1064) - Beckett - 21.07.2015

Solved.


Re: SQL (error #1064) - Crystallize - 21.07.2015

Mind telling the steps how you solve it? I would appreciate it a lot
Thanks!


Re: SQL (error #1064) - Krokett - 21.07.2015

My guess would be: int is a reserved keyword thus he needed to add quotation marks to int.


Re: SQL (error #1064) - Evocator - 22.07.2015

Quote:
Originally Posted by Wizzard2H
Посмотреть сообщение
Mind telling the steps how you solve it? I would appreciate it a lot
Thanks!
Basically:
Код:
INSERT INTO `texts` (`ID`,`distance`,`x`,`y`,`z`,`xx`,`yy`,`zz`,`text`,`vw`,`int`,`vww`,`intt`) VALUES ('%i','%i','%f','%f','%f','%f','%f','%f','%s','%i','%i','%i','%i')



Re: SQL (error #1064) - mamorunl - 22.07.2015

Quote:
Originally Posted by Krokett
Посмотреть сообщение
My guess would be: int is a reserved keyword thus he needed to add quotation marks to int.
That is exactly the problem. However, 'text' is a reserved word as well, that is why the error was right before the 'int'.

As a rule of thumb in MySQL:
Always add backticks to column names and table names and add single quotation marks (apostrophes) to string values.


Re: SQL (error #1064) - Beckett - 22.07.2015

Quote:
Originally Posted by mamorunl
Посмотреть сообщение
That is exactly the problem. However, 'text' is a reserved word as well, that is why the error was right before the 'int'.

As a rule of thumb in MySQL:
Always add backticks to column names and table names and add single quotation marks (apostrophes) to string values.
Yeah that's how I fixed it and thanks for the advice.