Mysql Saving Accounts and Loading... problem
#1

1. Hello
Second: I have a mysql script, i got it from my friend but it has some problems
1. Saving Accounts Doesn't work
2. Loading Cars...and stuffs

I have the .sql and i uploaded it to Xampp., mysql connect to the database, all things works, So what is the problem?

OnPlayerRegister

pawn Код:
public OnPlayerRegister(playerid, password[])
{
    FuncLog("OnPlayerRegister");
    if(IsPlayerConnected(playerid))
    {
        MySQLCheckConnection();
        new playername[MAX_PLAYER_NAME];
        new playername3[MAX_PLAYER_NAME];
        new newpass[64];
        GetPlayerName(playerid, playername3, sizeof(playername3));
        mysql_real_escape_string(playername3, playername);
        mysql_real_escape_string(password, newpass);
        new query[128];//PASSWORD
        format(query, sizeof(query), "INSERT INTO `userinfo` (Username) VALUES ('%s');", playername);
        mysql_query(query);
        new newaccountsqlid = MySQLCheckAccount(playername3);
        if (newaccountsqlid != 1)
        {
            format(query, sizeof(query), "INSERT INTO `uservehicles` (ID, Username) VALUES (%d, '%s');", newaccountsqlid, playername);
            mysql_query(query);
            format(query, sizeof(query), "INSERT INTO `userstrings` (ID, Username, Password) VALUES (%d, '%s', '%s');", newaccountsqlid, playername, newpass);
            mysql_query(query);
            format(query, sizeof(query), "INSERT INTO `userlocker` (ID, Username) VALUES (%d, '%s');", newaccountsqlid, playername);
            mysql_query(query);
            PlayerInfo[playerid][pSQLID] = newaccountsqlid;
            strmid(PlayerInfo[playerid][pKey], password, 0, strlen(password), 127);
            SendClientMessage(playerid, COLOR_YELLOW, "Account registered, you can now login.");
            ShowPlayerDialog(playerid, 115, DIALOG_STYLE_INPUT, "{00BFFF}Westcoast Roleplay", "This account is Registered!\nPlease enter your Password!", "Login", "Exit");
            gPlayerAccount[playerid] = 1;
            OnPlayerLogin(playerid, password);
            gPlayerLogged[playerid] = 1;
            return 1;
        }
        else
        {
            SendClientMessage(playerid, COLOR_BRIGHTRED, "There was an error creating your account. You will be disconnected now.");
            gPlayerLogged[playerid] = 0;
            Kick(playerid);
            return 0;
        }
    }
    return 0;
}
Mysql Connections

pawn Код:
public MySQLConnect(sqlhost[], sqluser[], sqlpass[], sqldb[])
{
    FuncLog("MySQLConnect");
    print("MYSQL: Attempting to connect to server...");
    new MySQL:connection;
    if(DEBUG == 1)
    {
        connection = mysql_init(LOG_ALL, 0);
    }
    else
    {
        connection = mysql_init(LOG_ONLY_ERRORS, 0);
    }
    mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB, connection, 1);
    if(mysql_ping() == 0)
    {
        print("MYSQL: Database connection connected.");
        return 1;
    }
    else
    {
        print("MYSQL: Could not connect! Retrying...");
        mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB, connection, 1);
        if(mysql_ping()==0)
        {
            print("MYSQL: Reconnection successful!");
            return 1;
        }
        else
        {
            print("MYSQL: Could not reconnect to Database! Terminating server...");
            SendRconCommand("exit");
            return 0;
        }
    }
}

public MySQLCheckConnection()
{
    //FuncLog("MySQLCheckConnection");
    if(mysql_ping()==0)
    {
        return 1;
    }
    else
    {
        print("MYSQL: Connection is dead! Attempting to reconnect...");
        mysql_close();
        MySQLConnect(MYSQL_HOST,MYSQL_USER,MYSQL_PASS,MYSQL_DB);
        if(mysql_ping()==0)
        {
            print("MYSQL: Reconnection successful!");
            return 1;
        }
        else
        {
            print("MYSQL: Could not reconnect to Database! Terminating server...");
            SendRconCommand("exit");
            return 0;
        }
    }
}
Reply
#2

Answer?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)