SQL (error #1064)
#1

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

Solved.
Reply
#3

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

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

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')
Reply
#6

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)