17.08.2016, 18:33
Hey,
So I've got this code that allows admins to change a players password, whilst offline in case they have forgotten it, now atm it recognises the name you type, and identifies if the account exists or not, however I'm getting a weird mysql log, error which I can't for the life of me work out why it won't process the query, any help appreciated.
The public function is also forwarded.
Also table & field names are correct.
Error Log
Thanks in advance.
So I've got this code that allows admins to change a players password, whilst offline in case they have forgotten it, now atm it recognises the name you type, and identifies if the account exists or not, however I'm getting a weird mysql log, error which I can't for the life of me work out why it won't process the query, any help appreciated.
Код:
public OnAccountSetPass(playerid,newpass[], name[]) { new query[512],string[128]; if(!cache_num_rows()) { return SendClientMessage(playerid, COLOR_RED, "Invalid Account Name"); } else { mysql_format(mysql,query, sizeof(query), "UPDATE Users SET pPass='%s' WHERE Name = '%s'",newpass,name); mysql_tquery(mysql, query,"", ""); format(string,sizeof(string),"Admin Log: %s has changed %s's password",GetName(playerid),name); ABroadCast(COLOR_ADMIN,string,1); } return 1; }
Код:
CMD:asetpass(playerid,params[]) { new Query[128],name,password[129]; if(PlayerInfo[playerid][pAdmin] < 5) return 0; if(sscanf(params,"s[30]s[16]",name,params)) return SendClientMessage(playerid,-1,"/asetpass [Name] [New Password]"); if(strlen(params) < 5) return SendClientMessage(playerid,-1,"The password must be longer than 5 characters"); WP_Hash(password,sizeof(password),params); mysql_format(mysql, Query, sizeof(Query), "SELECT * FROM Users WHERE Name = '%s' LIMIT 1",name); mysql_tquery(mysql, Query, "OnAccountSetPass", "ss",password,name); return 1; }
Error Log
Код:
[20:16:30] [DEBUG] Calling callback "OnAccountSetPass".. [20:16:30] [DEBUG] cache_get_row_count - connection: 1 [20:16:30] [DEBUG] mysql_format - connection: 1, len: 512, format: "UPDATE Users SET pPass='%s' WHERE Name = '%s'" [20:16:30] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE Users SET pPass='DSELECT * FROM Users WHERE Name = 'Dan' ", callback: "(null)", format: "(null)" [20:16:30] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [20:16:30] [DEBUG] CMySQLQuery::Execute[] - starting query execution [20:16:30] [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 'Dan' LIMIT 1' WHERE Name = ''' at line 1 [20:16:30] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError