Mysql checking if an account exists problem
#1

What's wrong with this?
pawn Код:
forward CheckPlayer(playerid);

public CheckPlayer(playerid)
{
    new string[256], PlayerName[MAX_PLAYER_NAME], EscapedName[MAX_PLAYER_NAME];
    mysql_store_result();
    GetPlayerName(playerid,PlayerName, sizeof(PlayerName));
    mysql_real_escape_string(PlayerName, EscapedName);
    format(string, sizeof(string), "SELECT * from accounts WHERE Username='%s' LIMIT 1", EscapedName);
    mysql_query(string);
    if(mysql_num_rows() != 0) {
        ShowPlayerDialog(playerid, Dialog_Login, DIALOG_STYLE_INPUT, "Notice", "This account is registered, if you are the account owner please login", "Login", "Close");
    } else {
        ShowPlayerDialog(playerid, Dialog_Register, DIALOG_STYLE_INPUT, "Notice", "This account is not registered, if you wish to register this account please enter a password below", "Register", "Close");
    }
    mysql_free_result();
    return 1;
}
Reply
#2

pawn Код:
forward CheckPlayer(playerid);

public CheckPlayer(playerid)
{
    new string[256], PlayerName[MAX_PLAYER_NAME], EscapedName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,PlayerName, sizeof(PlayerName));
    mysql_real_escape_string(PlayerName, EscapedName);
    format(string, sizeof(string), "SELECT * from accounts WHERE Username='%s' LIMIT 1", EscapedName);
    mysql_query(string);
    mysql_store_result();
    if(mysql_num_rows() != 0) {
        ShowPlayerDialog(playerid, Dialog_Login, DIALOG_STYLE_INPUT, "Notice", "This account is registered, if you are the account owner please login", "Login", "Close");
    } else {
        ShowPlayerDialog(playerid, Dialog_Register, DIALOG_STYLE_INPUT, "Notice", "This account is not registered, if you wish to register this account please enter a password below", "Register", "Close");
    }
    mysql_free_result();
    return 1;
}
Reply
#3

Cheers
Reply
#4

Quote:
Originally Posted by XcorelloX
Посмотреть сообщение
pawn Код:
// Code
Actually say what you changed and why, instead of just posting some code. How is he supposed to learn if he doesn't/didn't know what he did wrong?
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
Actually say what you changed and why, instead of just posting some code. How is he supposed to learn if he doesn't/didn't know what he did wrong?
He is supposed to learn by reading the code, comparing and realizing for himself. They don't give you questions in school and an answer book to look at. He's not stupid, he can inspect it himself without me writing a detailed explanation to what he did wrong.

Simply by reading my code, he can see that I had moved the mysql_store_result(); below the query, whereas in his code it was above the query. Therefore, by him noticing that he will remember that mysql_store_result(); comes after the query and not before.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)