Server crash after sending query to mysql
#1

Hai

I'm working on converting my register/login to MySQL but now the server crashes when I do /register blahblah or /login blahblah.

Code:
[13:35:32] Incomming connection: <ip>:2904
[13:35:32] [join] Some_Player has joined the server (0:<ip>)
[13:35:32] Some_Player (<ip>) has not been found on the Sprunk Buster blacklist.
[13:35:43] MySQL Debug: (login) Real escape succesful
[13:35:43] MySQL Debug: (login) Sent query to MySQL
-> Server crashes
pawn Code:
public OnPlayerLogin(playerid, password[])
{
   
    if(!strlen(password))
    {
        SendClientMessage(playerid, COLOR_GRAD2, " Syntax: /login <password>");
        return 1;
    }
   
    new pName[32];
    MySQLCheckConnection();
   
    samp_mysql_real_escape_string(PlayerName(playerid), pName);
    samp_mysql_real_escape_string(password, password);
    print("MySQL Debug: (login) Real escape succesful");
   
    format(query, sizeof(query), "SELECT * FROM `PlayerInfo` WHERE UserName = '%s'", pName);
    samp_mysql_query(query);
    print("MySQL Debug: (login) Sent query to MySQL");
   
    if(!samp_mysql_num_rows()) // if no rows found, nick doesn't exists
    {
        SendClientMessage(playerid, COLOR_YELLOW, " This nick is not found in the database.");
        SendClientMessage(playerid, COLOR_YELLOW, " You can register an account by using /register <password>");
        return 1;
    }
   
   
    format(query,sizeof(query),"SELECT * FROM `PlayerInfo` WHERE Username = '%s' AND Password = md5('%s') LIMIT 1", pName, password);
    samp_mysql_query(query);
    samp_mysql_store_result();

    if(samp_mysql_num_rows() == 1) // If username and password match ...
    {
        samp_mysql_fetch_row(resultline);
        samp_mysql_get_field("Id", field);
        format(string, sizeof(string), "Login Successful! Your user id is %d", strval(field));
        SendClientMessage(playerid, COLOR_YELLOW, string);
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Username and password do not match!");
        return 1;
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)