SQL not retrieving
#1

pawn Код:
public OnPlayerConnect(playerid)
{
    PlayerInfo[playerid][Logged] = 0;
   
    new query[128];
    mysql_format(g_Handle, query, sizeof(query), "SELECT * FROM `users` WHERE `name` = '%e' LIMIT 1", GetPName(playerid));
    mysql_tquery(g_Handle, query, "CheckPlayerExists", "i", playerid);

    return 1;
}
pawn Код:
public CheckPlayerExists(playerid)
{
    new rows, fields;
    cache_get_data(rows, fields, g_Handle);
    if(rows)
    {
        cache_get_field_content(0, "password", PlayerInfo[playerid][Password]);
        printf("%s", PlayerInfo[playerid][Password]); //debug
        print("Exists!); //debug
        ShowLogin(playerid);
    }
    else
    {
        print("
Does not exist."); //debug
        ShowRegister(playerid);
    }
    return 1;
}

This is not retrieving the password from the database and I can't figure out why. I'm using blueG's r39-3 and recently converted to it so I guess I did something wrong. Can anyone correct me?
Reply
#2

Well..did you looked at your table..does this row really exist?
Reply
#3

Yes, the row exists.
Reply
#4

Then print the query..and use phpmyadmin to find the mistake

or look in the mysql_debug
Reply
#5

Код:
[15:26:22] [DEBUG] Calling callback "CheckPlayerExists"..
[15:26:22] [DEBUG] cache_get_data - connection: 1
[15:26:22] [DEBUG] cache_get_field_content - row: 0, field_name: "password", connection: 1, max_len: 1
[15:26:22] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "password", data: "hidden"
[15:26:22] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
This seems healthy to me
Reply
#6

When using MYSQL if you want to use strings in enums as a destination you need to provide the string length yourself
PHP код:
cache_get_field_content(0"password"PlayerInfo[playerid][Password],1,30); 
Where you should change 30 to fit the size of Password in your playerinfo enum
Reply
#7

Quote:
Originally Posted by PrO.GameR
Посмотреть сообщение
When using MYSQL if you want to use strings in enums as a destination you need to provide the string length yourself
PHP код:
cache_get_field_content(0"password"PlayerInfo[playerid][Password],1,30); 
Where you should change 30 to fit the size of Password in your playerinfo enum
Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)