Mysql_Get_Feild bug.
#1

I get this error

Код:
[01:18:59] CMySQLHandler::FetchField(level) - You cannot call this function now. (Reason: Fields/Rows are empty.)
on this line

pawn Код:
mysql_get_field("level", pdata); playerdata[playerid][level] = strval(pdata);
Whats causing this?

(I switched from strikenkids to gstylez, so ive been fixing bugs with the switch all night. This is a bug i cant figure out.)
Reply
#2

try something like:
pawn Код:
if(mysql_retrieve_row())
{
mysql_get_field("level", pdata); playerdata[playerid][level] = strval(pdata);
}
Reply
#3

Heres the entire dialog.

pawn Код:
if(dialogid ==2)
    {
        TogglePlayerControllable(playerid, 0);
        new string[64], pname[MAX_PLAYER_NAME], query[128];
        GetPlayerName(playerid, pname, sizeof(pname));
        format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `name` = '%s' AND `password` = md5('%s');", pname, inputtext);
        mysql_query(query); mysql_store_result();
        if(mysql_num_rows() == 0)
        {
            format(string, 256, "You specified the wrong password for %s!", pname);
            SendClientMessage(playerid, red, string);
            ShowPlayerDialog(playerid, 2, 1,"Wrong Password", "That Password is incorrect. Please try again.","login", "cancel");
        }
        else
        {
            new pdata[128];
            mysql_get_field("level", pdata); playerdata[playerid][level] = strval(pdata);
            mysql_get_field("Joins", pdata); playerdata[playerid][Joins] = strval(pdata);
            mysql_get_field("Deaths", pdata); playerdata[playerid][Deaths] = strval(pdata);
            mysql_get_field("Kills", pdata); playerdata[playerid][Kills] = strval(pdata);
            mysql_get_field("Kicks", pdata); playerdata[playerid][Kicks] = strval(pdata);
            mysql_get_field("Banned", pdata); playerdata[playerid][Banned] = strval(pdata);
            mysql_get_field("BanReason", pdata); playerdata[playerid][BanReason] = strval(pdata);
            mysql_get_field("Score", pdata); playerdata[playerid][Score] = strval(pdata);
            mysql_get_field("Money", pdata); playerdata[playerid][Money] = strval(pdata);
            mysql_get_field("Slots", pdata); playerdata[playerid][Slots] = strval(pdata);
            if(playerdata[playerid][Banned]==1)
            {
                SendClientMessage(playerid, COLOR_RED,"You are banned, so go away!");
                Kick(playerid);
            }
            else
            {
                playerdata[playerid][logged] = 1;
                SendClientMessage(playerid, green, "You have succesfully logged in!");
                PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
                new pip[16];
                GetPlayerIp(playerid, pip, sizeof(pip));
                printf("%s (%i) logged in with the ip %s", pname, playerid, pip);
                SetTimerEx("Save", 25000, true, "i", playerid);
            }
        }
        mysql_free_result();
        if(response == 0)
        {
            SendClientMessage(playerid, red, "Screw You To, Bye!");
            Kick(playerid);
        }
        return 1;
    }
Reply
#4

You forgot to do mysql_retrieve_row(); to retrieve the next row in the query. Read the error next time: "Reason: Fields/Rows are empty."

/facepalm
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)