MySQL r37 account login problem
#1

Hello im having an issue with loading a players account.
it saves everything perfectly to the DB but then when you leave and then join again all variables are set too 0

Код:
public OnAccountLoad(playerid)
{
    PlayerInfo[playerid][pAdminLevel] = cache_get_field_content_int(0, "AdminLevel");
    TogglePlayerSpectating(playerid, false);
    SpawnPlayer(playerid);

    SendClientMessage(playerid, -1, "You have successfully logged in.");
    return 1;
}

public OnAccountCheck(playerid)
{
    new rows, fields;
    cache_get_data(rows, fields, mysql);
    if(rows)
    {
        cache_get_field_content(0, "Password", PlayerInfo[playerid][Password], mysql, 129);
        ShowPlayerDialog(playerid, LoginDialog, DIALOG_STYLE_INPUT, "Login", "Welcome player!\nYour account has been found in our database. Please fill in your password:", "Login", "Quit");
    }
    else
    {
        ShowPlayerDialog(playerid, RegisterDialog, DIALOG_STYLE_INPUT, "Register", "Welcome player!\nYour account has not been registered yet. Please fill in your desired password:", "Register", "Quit");
    }
    return 1;
}
For example i set my selft as admin level 3, then leave it saves to the DB
i then log back into my account and my admin level is 0
Reply
#2

Post the SQL log of what happends when you login & what happends when you create a new account. There might be an SQL error.
Reply
#3

Код:
[14:26:37] [DEBUG] mysql_format - connection: 1, len: 128, format: "UPDATE `accounts` SET `AdminLevel` = '%d' WHERE `Name` = '%e'"
[14:26:37] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `accounts` SET `AdminLevel` = '4' WHERE `Name` = 'Aspire5", callback: "(null)", format: "(null)"
[14:26:37] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[14:26:37] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 66.489 milliseconds
[14:26:37] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
[14:28:15] [DEBUG] mysql_connect - host: "localhost", user: "root", database: "myserver", password: "****", port: 3306, autoreconnect: true, pool_size: 2
[14:28:15] [DEBUG] CMySQLHandle::Create - creating new connection..
[14:28:15] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called
[14:28:15] [DEBUG] CMySQLHandle::Create - connection created (id: 1)
[14:28:15] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[14:28:15] [DEBUG] CMySQLConnection::Connect - connection was successful
[14:28:15] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[14:28:15] [DEBUG] mysql_errno - connection: 1
[14:28:15] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[14:28:15] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[14:28:15] [DEBUG] CMySQLConnection::Connect - connection was successful
[14:28:15] [DEBUG] CMySQLConnection::Connect - connection was successful
[14:28:15] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[14:28:15] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[14:28:33] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT `Password`, `Name` FROM `accounts` WHERE `Name` = '%e' LIMIT 1"
[14:28:33] [DEBUG] mysql_tquery - connection: 1, query: "SELECT `Password`, `Name` FROM `accounts` WHERE `Name` = 'Aspire", callback: "OnAccountCheck", format: "i"
[14:28:33] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - starting query execution
[14:28:33] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - query was successfully executed within 0.465 milliseconds
[14:28:33] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[14:28:33] [DEBUG] Calling callback "OnAccountCheck"..
[14:28:33] [DEBUG] cache_get_data - connection: 1
[14:28:33] [DEBUG] cache_get_field_content - row: 0, field_name: "Password", connection: 1, max_len: 129
[14:28:33] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Password", data: "50A09AF1575142623B1F8ABE28B433E108D6E8FCB3C7150F36DA7D0A359E22B7078EDC245278C84BEB1D3E634058D322399B9D29E2983F803C3F8B48507EC01E"
[14:28:33] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[14:28:35] [DEBUG] mysql_format - connection: 1, len: 100, format: "SELECT * FROM `accounts` WHERE `Name` = '%e' LIMIT 1"
[14:28:35] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM `accounts` WHERE `Name` = 'Aspire5630' LIMIT 1", callback: "OnAccountLoad", format: "i"
[14:28:35] [DEBUG] CMySQLQuery::Execute[OnAccountLoad] - starting query execution
[14:28:35] [DEBUG] CMySQLQuery::Execute[OnAccountLoad] - query was successfully executed within 0.346 milliseconds
[14:28:35] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[14:28:35] [DEBUG] Calling callback "OnAccountLoad"..
[14:28:35] [DEBUG] cache_get_field_content_int - row: 2, field_name: "AdminLevel", connection: 1
[14:28:35] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('2')
[14:28:35] [ERROR] cache_get_field_content_int - invalid datatype
[14:28:35] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[14:28:39] [DEBUG] mysql_format - connection: 1, len: 128, format: "UPDATE `accounts` SET `AdminLevel` = '%d' WHERE `Name` = '%e'"
[14:28:39] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `accounts` SET `AdminLevel` = '0' WHERE `Name` = 'Aspire5", callback: "(null)", format: "(null)"
[14:28:39] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[14:28:39] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 61.463 milliseconds
[14:28:39] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
Reply
#4

Are you sure you're setting the adminlevel right in your set admin level command?

e.g:
PHP код:
CMD:setlevel(playeridparams[])
{
    
PlayerInfo[playerid][pAdminLevel] = 3// assuming you want to be level 3
    
return 1;

Reply
#5

Quote:
Originally Posted by Jimmy0wns
Посмотреть сообщение
Are you sure you're setting the adminlevel right in your set admin level command?

e.g:
PHP код:
CMD:setlevel(playeridparams[])
{
    
PlayerInfo[playerid][pAdminLevel] = 3// assuming you want to be level 3
    
return 1;

yes thats exactly how im setting it. like i say it saves perfectly the DB untill you re-connect and login then it resets it to 0
Reply
#6

You're not even requesting a query, this could do the job:

PHP код:
public OnAccountLoad(playerid)
{
    new 
query[128];
    
    
format(querysizeof(query), "SELECT * FROM `accounts` WHERE Name = '%e'"GetPlayerNameEx(playerid0)); // replace getplayernameex with your own function
    
new Cache:result mysql_query(MySQL_Connectionquery); // replace mysql_connection with your own
    
new count cache_get_row_count();
    
    for(new 
0counti++)
    {
        
PlayerInfo[playerid][pAdminLevel] = cache_get_field_content_int(0"AdminLevel");
    }
    
TogglePlayerSpectating(playeridfalse);
    
SpawnPlayer(playerid);
    
SendClientMessage(playerid, -1"You have successfully logged in.");
    return 
1;

I haven't tested it, but it might work.
Reply
#7

Heres the full system
might be better to see the whole thing


http://pastebin.com/BTCdKkBp
Reply
#8

PHP код:
[14:28:35] [DEBUGcache_get_field_content_int row2field_name"AdminLevel"connection1
[14:28:35] [ERRORCMySQLResult::GetRowDataByName() - invalid row index ('2'
Read that please.
Reply
#9

[quote=TwinkiDaBoss;3630907]
PHP код:
[14:28:35] [DEBUGcache_get_field_content_int row2field_name"AdminLevel"connection1
[14:28:35] [ERRORCMySQLResult::GetRowDataByName() - invalid row index ('2'
Il screenshot the DB
Reply
#10

Quote:
Originally Posted by TwinkiDaBoss
Посмотреть сообщение
PHP код:
[14:28:35] [DEBUGcache_get_field_content_int row2field_name"AdminLevel"connection1
[14:28:35] [ERRORCMySQLResult::GetRowDataByName() - invalid row index ('2'
Read that please.
hey i dont understand? its column 2?

heres the DB
http://snag.gy/3q4RR.jpg

EDIT oh so that needs to be 0?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)