new query[300];
format(query, sizeof (query), "DELETE `pass`, `salt` FROM `users` WHERE `id` = '%i'",
gPlayerInfo[playerid][pPass], gPlayerInfo[playerid][pSalt], gPlayerInfo[playerid][pID]);
mysql_function_query(gHandle, query, false, "", "", "");
new query[300];
format(query, sizeof (query), "DELETE `pass`, `salt` FROM `users` WHERE `id` = '%i'",
gPlayerInfo[playerid][pID]);
mysql_function_query(gHandle, query, false, "", "", "");
format(query, sizeof (query), "UPDATE `users` DELETE `pass`, `salt` FROM `users` WHERE `id` = '%i'", gPlayerInfo[playerid][pID]);
mysql_function_query(gHandle, query, false, "", "");
I'll tell you this: Neither of you are even close! As I said, go learn SQL.
|
format(query, sizeof (query), "UPDATE `users` DELETE `pass`, `salt` FROM `users` WHERE `id` = '%i'", gPlayerInfo[playerid][pID]);
mysql_function_query(gHandle, query, false, "", "");
new query[300];
format(query, sizeof (query), "DELETE `pass` FROM `users` WHERE `id` = '%i'",
gPlayerInfo[playerid][pID]);
mysql_function_query(gHandle, query, false, "", "", "");
new query2[300];
format(query2, sizeof (query2), "DELETE `salt` FROM `users` WHERE `id` = '%i'",
gPlayerInfo[playerid][pID]);
mysql_function_query(gHandle, query2, false, "", "", "");
new query[300];
format(query, sizeof (query), "DELETE `pass` FROM `users` WHERE `id` = '%i'",
gPlayerInfo[playerid][pID]);
mysql_function_query(gHandle, query, false, "", "", "");
new query2[300];
format(query2, sizeof (query2), "DELETE `salt` FROM `users` WHERE `id` = '%i'",
gPlayerInfo[playerid][pID]);
mysql_function_query(gHandle, query2, false, "", "", "");
[04:38:10] [DEBUG] mysql_escape_string - source: "haistavittu", connection: 1, max_len: 512 [04:38:10] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `users` SET `pass`='9261DF172F8C1821CB028D83E92E97FB22FFA", callback: "query", format: "(null)" [04:38:10] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called [04:38:10] [DEBUG] mysql_tquery - scheduling query "UPDATE `users` SET `pass`='9261DF172F8C1821CB028D83E92E97FB22FFAC69BC8DCFCCB41AC8B18C672A47BDED211170D8737E3569DD609C28E71B0FE3C884E33D30BC975E739632E9A2BE', `salt`='lkGpJ801745495045A0E6Jazb9m0269261DF172F8C1821CB028D83E92E97FB22FFAC69BC8".. [04:38:10] [DEBUG] CMySQLQuery::Execute[query()] - starting query execution [04:38:10] [ERROR] CMySQLQuery::Execute[query()] - (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 ''lkGpJ801745495045A0E6Jazb9m0269261DF172F8C1821CB028D83E92E97FB22FFAC69BC8' at line 1
CMD:changepass(playerid, params[])
{
if (gPlayerInfo[playerid][pLogged] == 0)
return SendClientMessage( playerid, -1, "You need to be logged in to use this. " );
new newpass[129];
if(sscanf(params, "s[128]", newpass))
return SendClientMessage( playerid, -1, "USAGE: /changepass [New password]. " );
if (strlen(params) > 90)
return SendClientMessage(playerid, -1, "Password has to be between 1 and 90 characters.");
new Salt[30];
randomString(Salt, SALT_LENGTH);
format(newpass, sizeof(newpass), "%s%s", Salt, escape(newpass));
WP_Hash(newpass, 129, newpass);
new query[240];
format(query, sizeof(query), "UPDATE `users` SET `pass`='%s', `salt`='%s' WHERE `id`='%i'", newpass, Salt, gPlayerInfo[playerid][pID]);
mysql_function_query(gHandle, query, false, "query", "", "");
SendClientMessage(playerid, -1, "You have successfully changed your password.");
new string[70];
format(string,sizeof(string),"Your new password is %s", newpass);
SendClientMessage(playerid, -1, string);
return 1;
}
format(newpass, sizeof(newpass), "%s%s", Salt, escape(newpass));
That depends on your definition of "help". I know the answer because I have studied SQL as a language and read the documentation. I have done this because I recognise that it is a whole language in- and of-itself, and not just a minor add-on to PAWN you can master in five minutes.
So yes, I could use the knowledge I have gained from taking the time to learn this language to give a one-line answer on how to do exactly this one thing, but that won't help anyone. They will know how to do this one exact thing, but won't understand why the magic string of words I posted did it, or how to modify those words for the next slightly different situation. Do you think I know how to do this because I have encountered exactly the same situation before, asked someone, and been told the exact answer to parrot back to you now? Because if so I can tell you for a fact that that isn't the case. Once, many years ago, I was where you are - a n00b asking how to do every little thing, and someone did to me what I am doing to you now (I still know exactly who it was, and considered them a good friend for years after, but have sadly lost touch now). They went by the mantra "teach a man to fish" - instead of just spoon-feeding me the answer, they pointed me at the documentation that was available and gave me a good kick to go read it. I think many people will agree that it clearly worked, and as a graduate of this "help them help themselves" method I wouldn't have it any other way. So yes, I can help, and will help, by telling you to read the documentation carefully. |
format(newpass, sizeof(newpass), "%s%s", Salt, escape(newpass));
WP_Hash(newpass, 129, newpass);
WP_Hash(newpass, 129, newpass);
format(newpass, sizeof(newpass), "%s", escape(newpass));
If they knew all of SQL except for DELETE they would already have the answer since the answer is not in DELETE - hence why you were all way off. I would also expect someone adept at a language to already know of the documentation, having used it extensively, and know to go there to plug holes in their knowledge. If I forget the difference between LEFT INNER JOIN and RIGHT INNER JOIN, I don't post a topic here I just check the documentation.
This forum is not here to do things for people (despite popular opinion), it is here to point them in the right direction. In this case, the right direction is SQL documentation. Just to make that even more explicit: http://dev.mysql.com/doc/ <- Very comprehensive documentation. http://use-the-index-luke.com/ <- Guides to optimisation. https://www.******.co.uk/search?num=...53.IQAXELkZWAI <- SQL tutorials. I'd say look at any except the W3Schools one. |