sql problem
#1

pawn Код:
public OnPlayerRegister(playerid, password[])
{
        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 != 0)
        {
            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}", "This account is Registered!\nPlease enter your Password!", "Login", "Exit");
            gPlayerAccount[playerid] = 1;
            OnPlayerLogin(playerid, password);
            return 1;
        }
        else
        {
            SendClientMessage(playerid, COLOR_BRIGHTRED, "Error");
            gPlayerLogged[playerid] = 0;
            Kick(playerid);
            return 0;
        }
    }
    return 0;
}
Hey guys, Look, I loaded the .sql with XAMPP and database connect to the server without any problems but when i register In the BLOW, it should transfer me to the rules, but nothing happen

MysqlCheckAccount:

pawn Код:
public MySQLCheckAccount(sqlplayersname[])
{
    new query[128];
    new escstr[MAX_PLAYER_NAME];
    mysql_real_escape_string(sqlplayersname, escstr);
    format(query, sizeof(query), "SELECT `id` FROM `userinfo` WHERE LOWER(UserName) = LOWER('%s') LIMIT 1 ;", escstr);
    mysql_query(query);
    mysql_store_result();
    if (mysql_num_rows()==0)
    {
        return 0;
    }
    else
    {
        new strid[32];
        new intid;
        mysql_fetch_row(strid);
        intid = strval(strid);
        return intid;
    }
}
help me
Reply
#2

does it show Error or does it show account registerd? .. we are not genius by looking at code dude try debugging maybe? sql logs?
Reply
#3

Do you get any indications to your samp_server after the main(); that the MySQL even loads?
What i mean is are you sure you are connected to the DB, do other things save or you are just experimenting with a new script yet?
Also check if all tables are there- remember, password and username must be VARCHAR(24), others can be INT(11)
Reply
#4

Okay, let me check
Reply
#5

For example, here is what i am getting
Since my DB is down atm, i get an error connecting.

What kind of plugin are you using? Is your MYSQL_USER, MYSQL_PASS and etc inside your gamemode or in an mysql.ini file like: IP|USER|PASS|DATABASE

That will help us understand which kind of plugin you have atm.
Reply
#6

All things loaded and DB, still not, It says "Server Closed the connection" when i register
Reply
#7

Quote:

#define MYSQL_HOST "localhost"
#define MYSQL_USER "root"
#define MYSQL_PASS ""
#define MYSQL_DB "databased"

In the script. and it is Mysql plugin
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)