Registration Problem [MySQL]
#1

Hello,
whats wrong with this code?
pawn Код:
switch( dialogid )
        {
        case Register:
        {
            new
                Query[900],
                EscPass[100],
                EscName[MAX_PLAYER_NAME],
                IP[16];
            GetPlayerIp(playerid,IP,sizeof(IP));
            mysql_real_escape_string(GetPName(playerid), EscName);
            mysql_real_escape_string(inputtext, EscPass);
            format(Query, sizeof(Query), "INSERT INTO `playerdata` (User, Password, Cash, Level, EXP, Rank, TurfsCaptured, TurfsLost, Kills, Deaths, Score, Muted, Warnings, Vip, IP) VALUES('%s', '%s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s')", EscName,EscPass, IP);
            mysql_query(Query);
            PInfo[playerid][Regged] = 1;
            PInfo[playerid][Logged] = 1;
            TogglePlayerSpectating(playerid, 0);
            SendClientMessage(playerid,COLOR_ORANGE,"[*]: You Have Successfully Registered!");
        }
        case Login:
        {
            if(response)
            {
                new query[90], pname[24], escapepass[100];
                GetPlayerName(playerid, pname, 24);
                mysql_real_escape_string(inputtext, escapepass);
                format(query, sizeof(query), "SELECT `User` FROM `playerdata` WHERE `User` = '%s' AND Password = '%s'", pname, escapepass);
                mysql_store_result();
                TogglePlayerSpectating(playerid, 0);
                new numrows = mysql_num_rows();
                if(numrows == 1) MySQL_Login(playerid);
                if(!numrows)
                {
                    ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT,""COL_LIGHTBLUE":: "COL_RED"Login", "\t"COL_WHITE"Consipirational Team Death Match (V1.0)\n"COL_RED"You Have Entered Invalid Password\n"COL_WHITE"Welcome Back, \nPlease Enter Your Password Below To Start The Game!", "Login", "Exit");
                }
                mysql_free_result();
            }
        }
    }
        return 1;
}
it puts no data in tables plus players can login with INVALID password.
Reply
#2

Are you sure connection is alive and properly set up? Check with mysql_ping (if alive) and mysql_errno (if error occurs). Show us MySQL_Login function.

Also for now change

pawn Код:
format(Query, sizeof(Query), "INSERT INTO `playerdata` (User, Password, Cash, Level, EXP, Rank, TurfsCaptured, TurfsLost, Kills, Deaths, Score, Muted, Warnings, Vip, IP) VALUES('%s', '%s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s')", EscName,EscPass, IP);
//to
format(Query, sizeof(Query), "INSERT INTO `playerdata` (`User`, `Password`, `IP`) VALUES('%s', '%s', '%s')", EscName, EscPass, IP);
Reply
#3

pawn Код:
stock MySQL_Login(playerid)
{
    new query[900], pname[24], savingstring[50];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT Cash, Level, EXP, Rank, TurfsCaptured, TurfsLost, Kills, Deaths, Score, Muted, Warnings, Vip FROM playerdata WHERE User = '%s'", pname);
    mysql_query(query);
    mysql_store_result();
    while(mysql_fetch_row_format(query,"|"))
    {
        mysql_fetch_field_row(savingstring, "Cash"); GivePlayerMoney(playerid, strval(savingstring));
        mysql_fetch_field_row(savingstring, "Level"); PInfo[playerid][Level] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "EXP"); PInfo[playerid][EXP] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Rank"); PInfo[playerid][Rank] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "TurfsCaptured"); PInfo[playerid][TurfsCaptured] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "TurfsLost"); PInfo[playerid][TurfsLost] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Kills"); PInfo[playerid][Kills] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Deaths"); PInfo[playerid][Deaths] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Score"); PInfo[playerid][Score] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Muted"); PInfo[playerid][Muted] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Warnings"); PInfo[playerid][Warnings] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "Vip"); PInfo[playerid][Vip] = strval(savingstring);
    }
    mysql_free_result();
    TogglePlayerSpectating(playerid, 0);
    PInfo[playerid][Logged] = 1;
    SendClientMessage(playerid,COLOR_ORANGE,"[*]: You Have Successfully Logged In!");
    return 1;
}
Reply
#4

OnGameModeInit, after connecting mysql do:
pawn Код:
//
    if(mysql_ping() == 1)
    {
        mysql_debug(1);
        printf("[MYSQL] Connection with the database: SUCCESS!");
    }
    else
    {
        printf("[MYSQL] Connection with the database: FAIL!");
    }
And take a look in your server console, does it connect?

And dude, hash your passwords! People trust you, and you just can watch their passwords whenever you want?
Reply
#5

Under OnGameModeInit put
mysql_log(1);
then run the server and check what it sayd in the Debug.txt in the server directory
Reply
#6

Quote:
Originally Posted by Dan.
Посмотреть сообщение
OnGameModeInit, after connecting mysql do:
pawn Код:
//
    if(mysql_ping() == 1)
    {
        mysql_debug(1);
        printf("[MYSQL] Connection with the database: SUCCESS!");
    }
    else
    {
        printf("[MYSQL] Connection with the database: FAIL!");
    }
And take a look in your server console, does it connect?

And dude, hash your passwords! People trust you, and you just can watch their passwords whenever you want?
Hello,
Thank you for your help but server is passworded and only i can join.
Thats the only reason i am not HASHING the passwords right now.
When i make it public, passwords will probably be hashed.
By the way.
here is server.log.
Quote:

[23:31:57] Loaded 3 filterscripts.

[23:31:57] [MYSQL] Connection with the database: SUCCESS!
[23:31:57]
Developed by:
Littlehelper[MDZ]

Project Start:
Friday, July 20th, 2012


Last Update:
July 21th, 2012

Tables are created, but player information is not STORED in those.
Reply
#7

Probably the table name?
Tablenames are case sensitive
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)