MySQL Query Error 1064.
#1

Hi everyone, I am having a problem with a Quert in MySQL.

Error.
23:56:11] [DEBUG] mysql_format - connection: 1, len: 128, format: "UPDATE `users` SET `Admin` =`%d`, `Money`=`%d`, WHERE `ID`=`%d`"
[23:56:11] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `users` SET `Admin` =`0`, `Money`=`0`, WHERE `ID`=`0`", callback: "(null)", format: "(null)"
[23:56:11] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[23:56:11] [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 'WHERE `ID`=`0`' at line 1
[23:56:11] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError
[23:56:11] [DEBUG] Calling callback "OnQueryError"..

Code for where the error is.
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new query[128];
    mysql_format(mysql, query, sizeof(query), "UPDATE `users` SET `Admin` =%d, `Money`=%d, WHERE `ID`=%d",pInfo[playerid][Admin], pInfo[playerid][Money],pInfo[playerid][ID]);
    mysql_tquery(mysql, query, "", "");
    return 1;
}
Any ideas? Thanks!
Reply
#2

Change:
Код:
mysql_format(mysql, query, sizeof(query), "UPDATE `users` SET `Admin` =%d, `Money`=%d, WHERE `ID`=%d",pInfo[playerid][Admin], pInfo[playerid][Money],pInfo[playerid][ID]);
To:
Код:
mysql_format(mysql, query, sizeof(query), "UPDATE `users` SET `Admin` ='%d', `Money`='%d', WHERE `ID`='%d'",pInfo[playerid][Admin], pInfo[playerid][Money],pInfo[playerid][ID]);
Reply
#3

i think the problem is ", " Money=%d, here this coma you dont have to put that

put this

pawn Код:
mysql_format(mysql, query, sizeof(query), "UPDATE `users` SET `Admin` =%d, `Money`=%d WHERE `ID`=%d",pInfo[playerid][Admin], pInfo[playerid][Money],pInfo[playerid][ID]);
Reply
#4

Get rid of the stupid backticks altogether. I wonder where everyone gets that stuff. You only use them in case your column name is an SQL keyword, in which case you should seriously consider renaming that column.
Reply
#5

Quote:
Originally Posted by Namer
Посмотреть сообщение
i think the problem is ", " Money=%d, here this coma you dont have to put that

put this

pawn Код:
mysql_format(mysql, query, sizeof(query), "UPDATE `users` SET `Admin` =%d, `Money`=%d WHERE `ID`=%d",pInfo[playerid][Admin], pInfo[playerid][Money],pInfo[playerid][ID]);
Thank you, this worked like a charm!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)