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=598499)
MySQL Syntax Error -
venomlivno8 - 13.01.2016
Код:
[18:04:15] [DEBUG] mysql_format - connection: 1, len: 512, format: "UPDATE accounts SET admin = '%i' WHERE name = '%e' LIMIT 0,1"
[18:04:15] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE accounts SET admin = '1338' WHERE name = 'Dillon_Cozart' ", callback: "(null)", format: "(null)"
[18:04:15] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[18:04:15] [ERROR] CMySQLQuery::Execute[] - (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 '1' at line 1
[18:04:15] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError
What is the problem? I'm using the latest Blue-G's MySQL plugin R39-r4
Re: MySQL Syntax Error -
PrO.GameR - 13.01.2016
admin and name should be between two `, and I think you should change limit 0 to limit 1, not sure.
Re: MySQL Syntax Error -
valych - 13.01.2016
@PrO.GameR, the symbol ` - won't solve this problem I guess.
@venomlivno8, try to write your query in this way:
PHP код:
UPDATE accounts SET admin = '%i' WHERE name = '%e' LIMIT 1
Re: MySQL Syntax Error -
PrO.GameR - 14.01.2016
Quote:
Originally Posted by valych
@PrO.GameR, the symbol ` - won't solve this problem I guess.
@venomlivno8, try to write your query in this way:
PHP код:
UPDATE accounts SET admin = '%i' WHERE name = '%e' LIMIT 1
|
Obviously the problem is at LIMIT 0, but why not fix the code entirely while we are at it ?
Re: MySQL Syntax Error -
Vince - 14.01.2016
Is LIMIT even a valid keyword in an update statement? The fact that you need it makes me think that your tables aren't properly indexed. A username should be unique so there should not be any need to use LIMIT at all. Plus, using the players name as a key is a bad idea. Research primary keys.
Re: MySQL Syntax Error -
valych - 14.01.2016
@Vince, damn, dude, well done. I didn't even pay an attention that it is an UPDATE statement because of LIMIT statement usage.
Re: MySQL Syntax Error -
venomlivno8 - 14.01.2016
The problem was LIMIT 0,1
It is valid, but it's not needed, thanks for help, everyone repup!