MySQL Syntax Error
#1

Код:
[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
Reply
#2

admin and name should be between two `, and I think you should change limit 0 to limit 1, not sure.
Reply
#3

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

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 ?
Reply
#5

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

@Vince, damn, dude, well done. I didn't even pay an attention that it is an UPDATE statement because of LIMIT statement usage.
Reply
#7

The problem was LIMIT 0,1

It is valid, but it's not needed, thanks for help, everyone repup!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)