SA-MP Forums Archive
Mysql error 1064 on a simple query? - 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 error 1064 on a simple query? (/showthread.php?tid=599698)



Mysql error 1064 on a simple query? - thimo - 29.01.2016

Hello, can anyone find what i am doing wrong on this query:
pawn Код:
format(Query, sizeof(Query), "SELECT * FROM Users WHERE Name='%s' AND Password='%s'", pName, HashPW);
            mysql_tquery(Handle, Query, "PlayerAttemptLogin", "i", playerid);
It gives me this error in my mysql log:
Код:
[13:56:04] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FRO", callback: "PlayerAttemptLogin", format: "i"
[13:56:04] [DEBUG] CMySQLQuery::Execute[PlayerAttemptLogin] - starting query execution
[13:56:04] [ERROR] CMySQLQuery::Execute[PlayerAttemptLogin] - (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 'FRO' at line 1
[13:56:04] [DEBUG] CMySQLQuery::Execute[PlayerAttemptLogin] - error will be triggered in OnQueryError
Does anybody know what is going on because the query seems fine to me!


Re: Mysql error 1064 on a simple query? - Kwarde - 29.01.2016

Perhaps either pName or HashPW is empty (that is a reason why you could get error 1064).
Try printing both strings and see if it's actually a proper string.


Re: Mysql error 1064 on a simple query? - thimo - 29.01.2016



I have printed the strings to console, they are fine and both contain the right stuff, Any more idea's?


Re: Mysql error 1064 on a simple query? - JeaSon - 29.01.2016

have you tried ` ?
try

PHP код:
format(Querysizeof(Query), "SELECT * FROM `Users` WHERE `Name`='%s' AND `Password`='%s'"pNameHashPW); 



Re: Mysql error 1064 on a simple query? - thimo - 29.01.2016

I've tried that and mysql_log still gives out the same problem. I am kinda out of idea's here, it worked before. And i have changed nothing since then. Anyone still an idea?


Re: Mysql error 1064 on a simple query? - AmigaBlizzard - 29.01.2016

What's the length of the query variable?
Seems like it's been cut off after 12 characters.
Can you print the query like this?

PHP код:
format(Querysizeof(Query), "SELECT * FROM Users WHERE Name='%s' AND Password='%s'"pNameHashPW);
printf("%s"Query);
mysql_tquery(HandleQuery"PlayerAttemptLogin""i"playerid); 



Re: Mysql error 1064 on a simple query? - thimo - 29.01.2016

Dafuq, it only outputs till SELECT * FRO while the length of the string is 256 characters, thats weird:

Edit: tried changing the name of the string, still the same effect


Re: Mysql error 1064 on a simple query? - Mencent - 29.01.2016

It's very strange. Well, try this:
PHP код:
new Query[400];
format(Query,sizeof(Query),"SELECT * FROM `Users` WHERE `Name`='%s' AND `Password`='%s'",pName,HashPW);
mysql_tquery(Handle,Query,"PlayerAttemptLogin","i",playerid); 



Re: Mysql error 1064 on a simple query? - sammp - 29.01.2016

Error #1064 is an error when MySQL can't understand your query, ie you've done something wrong.

Try using mysql_format for a kick off, since format isn't really designed for MySQL queries.
Another thing to try is putting a semicolon ( at the end of the query.

Anyways, it's also a good tip just to put `` around what table you're selecting from, and the conditions etc, as there are reserved words in MySQL that could mess your queries up.




It couldn't be because the variable was empty Kwarde, as it would just simply select a null value, or the query would fail (not a #1064 fail - #1064 states that there should be something after the "near 'FRO' at line 1" point, or that there is a mismatch)


Re: Mysql error 1064 on a simple query? - Vince - 29.01.2016

I suspect stack corruption. Run crashdetect.