mysql register problem
#1

Hello, i very a problem with my mysql system. When i join for the first time it asks me to register, and until now is ok. But when i rejoin, i have to register again! Seems the server can't save the tables in the database.

Here is the stock which handles the registration:

pawn Код:
stock MySQL_Register(playerid, passwordstring[])
{
    new query1[256*2], pname[24];
    new Year, Month, Day, Hour, Minute, Second;
    getdate(Year, Month, Day);
    gettime(Hour, Minute, Second);
    new RegDate[128];
    format(RegDate, 128, "%d:%d:%d - %d/%d/%d", Hour, Minute, Second, Day, Month, Year);
    new Bannedby[20];
    format(Bannedby, 20, "Not Banned");
    GetPlayerName(playerid, pname, 24);
    format(query1, sizeof(query1), "INSERT INTO playerdata (user, password, Scores, Cash, Admin, Deaths, Nopm, Muted, Vip, Warn, RegisterDate, Jailed, AdminActions, Cookies, Rank, VipTime, Class, PrototypesStolen, KillAsUsaTeam, KillAsGermanyTeam, KillAsItalyTeam, KillAsJapanTeam, KillAsMercTeam, KillAsMexicoTeam, IP) VALUES('%s', SHA1('%s'), 0, 0, 0, 0, 0, 0, 0, 0, '%s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s')", pname, passwordstring, RegDate, GetIP(playerid));
    mysql_query(query1);
    Logged[playerid] = 1;
    WindowForPlayer(playerid, "You are now ~r~registered ~w~to Battlefield War Heroes! Enjoy playing!");
    WelcomeDialog(playerid);
    new echo[130];
    new kname[24];
    GetPlayerName(playerid, kname, 24);
    format(echo,sizeof(echo),"0,3** System: %s (%d) (IP: %s) has registered a new account",pname,playerid,GetIP(playerid));
    IRC_GroupSay(gGroupID, IRC_ACHANNEL, echo);
    new admin[128];
    format(admin,sizeof(admin),"** System: %s (%d) (%s) has registered a new account.",pname,playerid,GetIP(playerid));
    SendMessageToAdmins(LIGHTBLUE,admin);
    new txd[128];
    format(txd,sizeof(txd),"%s (%d) (IP: %s) registered a new account",pname,playerid,GetIP(playerid));
    TextDrawSetString(RegTxd, txd);
    new welcome[130];
    format(welcome, sizeof(welcome), "Welcome to Battlefield War Heroes, ~r~%s! Type ~r~/rules ~w~and ~r~/cmds ~w~for server info.",pname);
    GameTextForPlayer(playerid,welcome,6000,4);
    return 1;
}
And this is mysql log file:

Quote:


[21:11:20]

[21:11:20] ---------------------------

[21:11:20] MySQL Debugging activated (01/01/14)

[21:11:20] ---------------------------

[21:11:20]

[21:11:44] >> mysql_query( Connection handle: 1 )

[21:11:44] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)

[21:11:44] >> mysql_store_result( Connection handle: 1 )

[21:11:44] CMySQLHandler::StoreResult() - There is nothing to store (Reason: Connection is dead)

[21:11:44] >> mysql_num_rows( Connection handle: 1 )

[21:11:44] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection)

[21:11:44] >> mysql_fetch_row_format( Connection handle: 1 )

[21:11:44] CMySQLHandler::FetchRow() - You cannot call this function now. (Reason: Connection is dead)

[21:11:44] >> mysql_query( Connection handle: 1 )

[21:11:44] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)

[21:11:44] >> mysql_free_result( Connection handle: 1 )

[21:11:44] CMySQLHandler::FreeResult() - There is nothing to free (Reason: Connection is dead)

[21:11:44] >> mysql_query( Connection handle: 1 )

[21:11:44] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)

[21:11:44] >> mysql_store_result( Connection handle: 1 )

[21:11:44] CMySQLHandler::StoreResult() - There is nothing to store (Reason: Connection is dead)

[21:11:44] >> mysql_num_rows( Connection handle: 1 )

[21:11:44] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection)

[21:11:44] >> mysql_free_result( Connection handle: 1 )

[21:11:44] CMySQLHandler::FreeResult() - There is nothing to free (Reason: Connection is dead)

[21:11:52] >> mysql_query( Connection handle: 1 )

[21:11:52] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)

[21:11:59] >> mysql_query( Connection handle: 1 )

[21:11:59] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)

[21:12:44] >> mysql_query( Connection handle: 1 )

[21:12:44] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)

[21:12:44] >> mysql_store_result( Connection handle: 1 )

[21:12:44] CMySQLHandler::StoreResult() - There is nothing to store (Reason: Connection is dead)

[21:12:44] >> mysql_num_rows( Connection handle: 1 )

[21:12:44] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection)

[21:12:44] >> mysql_fetch_row_format( Connection handle: 1 )

[21:12:44] CMySQLHandler::FetchRow() - You cannot call this function now. (Reason: Connection is dead)

[21:12:44] >> mysql_query( Connection handle: 1 )

[21:12:44] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)

[21:12:44] >> mysql_free_result( Connection handle: 1 )

[21:12:44] CMySQLHandler::FreeResult() - There is nothing to free (Reason: Connection is dead)

[21:12:44] >> mysql_query( Connection handle: 1 )

[21:12:44] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)

[21:12:44] >> mysql_store_result( Connection handle: 1 )

[21:12:44] CMySQLHandler::StoreResult() - There is nothing to store (Reason: Connection is dead)

[21:12:44] >> mysql_num_rows( Connection handle: 1 )

[21:12:44] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection)

[21:12:44] >> mysql_free_result( Connection handle: 1 )

[21:12:44] CMySQLHandler::FreeResult() - There is nothing to free (Reason: Connection is dead)

[21:12:52] >> mysql_query( Connection handle: 1 )

[21:12:52] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)

[21:12:53] >> mysql_query( Connection handle: 1 )

[21:12:53] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)

The connection with the database is ok, the tables are already created and mysql_connect is placed on OnGameModeInit.
Reply
#2

Bump.
Reply
#3

First make sure you are connected to the database.

Show OnGameModeInit and your first queries.

@edit: From what moment his connection with DB is dead?
Reply
#4

Quote:
Originally Posted by Schocc
Посмотреть сообщение
First make sure you are connected to the database.

Show OnGameModeInit and your first queries.

@edit: From what moment his connection with DB is dead?
I said im connected to the database because the print returns "Connection succeed"

Here is OnGameModeInit (first queries)

pawn Код:
public OnGameModeInit()
{
    mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);

    if( mysql_ping() )
    {
    print( "Connection MySQL succeed" );
    }
    else
    {
    print( "Connection MySQL failed" );
    }
   
    mysql_debug(1);
About the connection to db, seems is dead when i register, but im not sure.
Reply
#5

The log says that you're not connected (dead connection) according to your MySQL log. I don't get the issue really, trying doing like this which will work like if your MySQL connection is dead it will exit the server.

pawn Код:
if(!mysql_ping())
{
    print(!"Failed to connect to the database.");
    SendRconCommand("exit");
    return false;
}
Reply
#6

Nothing, did the same step and server stays online. This means the connection is ok and stable. What can be the issue then?
Reply
#7

Bump.
Reply
#8

Fixed. The problem was the host. Thanks to Beremix who setup a tem database for the test.
Reply
#9

Put this:

pawn Код:
if(mysql_ping == 1)
{
   print("Mysql connction successfull.");
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)