SA-MP Forums Archive
Mysql syntax error - 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: Mysql syntax error (/showthread.php?tid=542419)



Mysql syntax error - TakeiT - 19.10.2014

I'm getting a syntax error here, I can't see what i've done. The cols are not misspelled.

pawn Код:
mysql_format(connection, query, sizeof(query), "SELECT `ID` FROM `houses` WHERE `ExtX` = %f, `ExtY` = %f, `ExtZ` = %f, `ExtA` = %f", X, Y, Z, A);
Код:
[23:44:05] [DEBUG] mysql_format - connection: 1, len: 200, format: "SELECT `ID` FROM `houses` WHERE `ExtX` = %f, `ExtY` = %f, `ExtZ` = %f, `ExtA` = %f"
[23:44:05] [DEBUG] mysql_tquery - connection: 1, query: "SELECT `ID` FROM `houses` WHERE `ExtX` = 2285.291, `ExtY` = 143.", callback: "OnHouseCreatedFinal", format: "ddffffd"
[23:44:05] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[23:44:05] [DEBUG] CMySQLQuery::Execute[OnHouseCreatedFinal] - starting query execution
[23:44:05] [ERROR] CMySQLQuery::Execute[OnHouseCreatedFinal] - (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 ' `ExtY` = 143.446, `ExtZ` = 26.336, `ExtA` = 299.682' at line 1
Thanks in advance.


Re: Mysql syntax error - zaibaslr2 - 19.10.2014

Try
Код:
"SELECT ID FROM `houses` WHERE ExtX = '%f', ExtY = '%f', ExtZ = '%f', ExtA = '%f'"



Re: Mysql syntax error - Vince - 19.10.2014

Testing multiple values in a 'where' clause requires an 'and' or 'or' operator. But i can almost certainly tell you that the query won't work anyway due to the way floats are stored and how they work.


Re: Mysql syntax error - 0x41726d79 - 19.10.2014

you can try to use that SQL on PhpMyadmin.. with random values.


Re: Mysql syntax error - TakeiT - 19.10.2014

I dont know what I was thinking lol, there's a chance that would bug, even if it did work. I used cache_insert_id() and it all worked w/o problems.