Mysql error 1064 on a simple query?
#1

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

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



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

have you tried ` ?
try

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

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

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); 
Reply
#7

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
Reply
#8

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); 
Reply
#9

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)
Reply
#10

I suspect stack corruption. Run crashdetect.
Reply


Forum Jump:


Users browsing this thread: