Problem with get data MySQL
#1

Hello,
MySQL : R34

Log :
pawn Код:
[13:03:29] CheckAccount IS OK !
[13:03:29] OnAccountCheck IS OK !
[13:03:29] Get rows is OK! rows : - fields :
[13:03:29] pSQLid :  - pPass :

pawn Код:
stock CheckAccount(playerid)
{
    new query[82];
    printf("CheckAccount IS OK !");
    format(query, sizeof(query), "SELECT id, Password FROM `users` WHERE `Username` = '%s'", returnName(playerid));
    mysql_function_query(1, query, true, "OnAccountCheck", "d", playerid);
    return 1;
}
pawn Код:
forward OnAccountCheck(playerid);
public OnAccountCheck(playerid)
{
    printf("OnAccountCheck IS OK !");
    if(playerid != INVALID_PLAYER_ID)
    {
   
        new rows, fields;
        cache_get_data(rows, fields);
        printf("Get rows is OK! rows : %s - fields : %s",rows,fields);
       
        if(rows)
        {
            Player[playerid][pSQLid] = cache_get_row_int(0, 0);
            cache_get_row(0, 3, Player[playerid][pPass], 1, 130);      
            printf("pSQLid : %s - pPass : %s",Player[playerid][pSQLid],Player[playerid][pPass]);
            ShowLoginScreen(playerid);
        }
        else
        {
            ShowRegisterScreen(playerid);
        }
    }
    return 1;
}
Reply
#2

what is the problem?
Reply
#3

rows, fields, pSQLid And pPass is empty.
pawn Код:
[13:03:29] Get rows is OK! rows : - fields :
[13:03:29] pSQLid :  - pPass :
Reply
#4

mysql_log.txt
pawn Код:
[13:02:53] [DEBUG] CMySQLHandle::Create - creating new connection..
[13:02:53] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called
[13:02:53] [DEBUG] CMySQLHandle::Create - connection created with ID = 1
[13:02:53] [DEBUG] CMySQLConnection::Connect - connection was successful
[13:02:53] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[13:02:53] [DEBUG] CMySQLConnection::Connect - connection was successful
[13:02:53] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[13:03:29] [DEBUG] mysql_tquery - connection: 1, query: "SELECT id, Password FROM `users` WHERE `Username` = 'Miami'", callback: "OnAccountCheck", format: "d"
[13:03:29] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called
[13:03:29] [DEBUG] mysql_tquery - scheduling query "SELECT id, Password FROM `users` WHERE `Username` = 'Miami'"..
[13:03:29] [DEBUG] CMySQLQuery::Execute[OnAccountCheck(d)] - starting query execution
[13:03:29] [DEBUG] CMySQLQuery::Execute[OnAccountCheck(d)] - query was successful
[13:03:29] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[13:03:29] [DEBUG] CMySQLQuery::Execute[OnAccountCheck(d)] - data being passed to ProcessCallbacks()
[13:03:29] [DEBUG] Calling callback "OnAccountCheck"..
[13:03:29] [DEBUG] cache_get_data - connection: 1
[13:03:29] [DEBUG] cache_get_row_int - row: 0, field_idx: 0, connection: 1
[13:03:29] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '0', data: "0"
[13:03:29] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[13:03:29] [DEBUG] CMySQLQuery::~CMySQLQuery() - deconstructor called
Reply
#5

Update your MySQL plugin, also use %d or %i for integers in printf.
Reply
#6

For sqlid use %d instead of %s in print line.
For pass, the cache_get_row line is wrong.
Here is the correct one :
Quote:

cache_get_row(0, 1, Player[playerid][pPass], 1, 130);

You had 3 in place of 1. It should be 1 as the index of password field is 1 according to your select line.
Reply
#7

Fixed. Thanks @xJayce @BroZeus
pawn Код:
[13:36:17] Get rows is OK! rows : 1 - fields : 2
[13:36:17] pSQLid : 0 - pPass : 07A199D9A7E21A62464B36B87BB8F4A26DE7B61A4BC0FFDCB621E6913FB9F66BF6019461335A0E105FB5F8A217CD
MyDB : http://uploadpie.com/ekuDF
When the row is 1? ( cache_get_row(1 ,....) )
Thanks.
Reply
#8

Quote:
Originally Posted by MRM
Посмотреть сообщение
Fixed. Thanks @xJayce @BroZeus
When the row is 1? ( cache_get_row(1 ,....) )
Thanks.
Row is 1 when there are more than one rows being selected. For example if you select all player data then number of rows in list is number of rows in the table.
Example :
PHP код:
mysql_function_query(1"SELECT id FROM `users`"true"Just_a_Example""");//see the query it will select id of all users
public Just_a_Example()
{
   new 
rows cache_get_row_count();//get num of rows in result
   
for(new 0;rowsi++)
   {
       new 
id cache_get_row_int(i0);//number of row changes here, see the 'i'
       
printf("User id :%d row: %d"idi); 
   }
   return 
1;

Reply
#9

Thanks .
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)