Mysql syntax error
#1

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

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

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)