stock MySQLCreateAccount(newplayersname[], newpassword[]) { new query[128]; new sqlplyname[64]; new sqlpassword[64]; mysql_real_escape_string(newplayersname, sqlplyname); mysql_real_escape_string(newpassword, sqlpassword); format(query, sizeof(query), "INSERT INTO playerinfo (user, password) VALUES ('%s', '%s')", sqlplyname, sqlpassword); mysql_query(query); new newplayersid = MySQLCheckAccount(newplayersname); if (newplayersid != 0) { return newplayersid; } return 0; }
mysql_real_escape_string(inputtext, escpass); //mysql_real_escape_string(PlayerInfo[playerid][pName],PlayerInfo[playerid][pName]); //mysql_real_escape_string(inputtext,inputtext); format(query, sizeof(query), "INSERT INTO playerdata (UserName, Password, IP) VALUES('%s', SHA1('%s'), '%s')", PlayerInfo[playerid][pName], escpass, PIP); mysql_query(query); //format(query, sizeof(query), "INSERT INTO playerdata (UserName, Password, IP) VALUES ('%s', md5('%s'), '%s')",PlayerInfo[playerid][pName], inputtext, PIP); //Insert string //mysql_query(query); format(query,sizeof(query),"UPDATE playerdata SET Registered = '%s' WHERE (UserName = '%s')",LastLogin,PlayerInfo[playerid][pName]); mysql_query(query); //queries format(query,sizeof(query),"UPDATE playerdata SET LastLogin = '%s' WHERE (UserName = '%s')",LastLogin,PlayerInfo[playerid][pName]); mysql_query(query); //queries mysql_free_result(); PlayerInfo[playerid][pLogged] = 1; PlayerInfo[playerid][pRegistered] = 1; //SendClientMessage(playerid, COLOR_SERVER_MAIN_MSG, "Registered And Logged In.");
mysql_log(ALL);
//Creates folder/files in /logs/
mysql_log(LOG_ALL, LOG_TYPE_HTML); //Or log_type_text. HTML is easier on the eyes.
What version of the plugin are you using?
R40+ pawn Код:
pawn Код:
|
SA-MP MySQL plugin R5 Copyright © 2008-2010, G-sTyLeZzZ
Whatever your gamemode is you should always update the version of every include or plugin you are using |
Can anybody figure out whats wrong here, when I join my server and /register it doesn't save to MySQL database, its connected properly because if I manually create a new account by adding it to the MySQL database it successfully loads in-game its just not saving for some reason
MySQLCreateAccount stock: Код:
stock MySQLCreateAccount(newplayersname[], newpassword[]) { new query[128]; new sqlplyname[64]; new sqlpassword[64]; mysql_real_escape_string(newplayersname, sqlplyname); mysql_real_escape_string(newpassword, sqlpassword); format(query, sizeof(query), "INSERT INTO playerinfo (user, password) VALUES ('%s', '%s')", sqlplyname, sqlpassword); mysql_query(query); new newplayersid = MySQLCheckAccount(newplayersname); if (newplayersid != 0) { return newplayersid; } return 0; } Код:
mysql_real_escape_string(inputtext, escpass); //mysql_real_escape_string(PlayerInfo[playerid][pName],PlayerInfo[playerid][pName]); //mysql_real_escape_string(inputtext,inputtext); format(query, sizeof(query), "INSERT INTO playerdata (UserName, Password, IP) VALUES('%s', SHA1('%s'), '%s')", PlayerInfo[playerid][pName], escpass, PIP); mysql_query(query); //format(query, sizeof(query), "INSERT INTO playerdata (UserName, Password, IP) VALUES ('%s', md5('%s'), '%s')",PlayerInfo[playerid][pName], inputtext, PIP); //Insert string //mysql_query(query); format(query,sizeof(query),"UPDATE playerdata SET Registered = '%s' WHERE (UserName = '%s')",LastLogin,PlayerInfo[playerid][pName]); mysql_query(query); //queries format(query,sizeof(query),"UPDATE playerdata SET LastLogin = '%s' WHERE (UserName = '%s')",LastLogin,PlayerInfo[playerid][pName]); mysql_query(query); //queries mysql_free_result(); PlayerInfo[playerid][pLogged] = 1; PlayerInfo[playerid][pRegistered] = 1; //SendClientMessage(playerid, COLOR_SERVER_MAIN_MSG, "Registered And Logged In."); |
SELECT * from users where name = `%s`