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



SQL syntax error - Rudey - 27.07.2015

Hey, upon logging on my server I don't get the registration/login dialog, so I went to check the MySQL log for any sort of error that occured. Apparently, there is something wrong with one of my queries.

[ERROR] CMySQLQuery::Execute[OnAccountCheck(i)] - (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 ''accounts' WHERE 'Name'=Rudey LIMIT 1' at line 1

Is there anything wrong with: "SELECT 'Password', 'ID' FROM 'accounts' WHERE 'Name'=%e" ?

Thanks in advance!


Re: SQL syntax error - BigGroter - 27.07.2015

Try replacing the ' with `. eg. `Password`


Re: SQL syntax error - Vince - 27.07.2015

Ironically, the only thing that requires quotes is not in quotes ('%e'). Avoid backticks if you can. While they're the safest way to build a query, they also lengthen it and make it hard to read.


Re: SQL syntax error - Rudey - 27.07.2015

Tried this: "SELECT `Password`, `ID` FROM `accounts` WHERE `Name`=`%e`" (With %e quoted, as Vince said) - Still doesn't work. I've also let the ticks I had initially, didn't work..


AW: SQL syntax error - Macronix - 27.07.2015

Have you also tried this version?

Код:
SELECT Password, ID FROM accounts WHERE Name = '%e'



Re: SQL syntax error - Vince - 27.07.2015

Quote:
Originally Posted by Rudey
Посмотреть сообщение
Tried this: "SELECT `Password`, `ID` FROM `accounts` WHERE `Name`=`%e`" (With %e quoted, as Vince said) - Still doesn't work. I've also let the ticks I had initially, didn't work..
That's not what I said. I said '%e', not `%e`. Huge difference. Does your computer render them as the same thing?


Re: SQL syntax error - Rudey - 27.07.2015

I'm aware. It works now, thank you.