Mysql errors
#1

pawn Код:
[21:01:48] [MySQL] Error (0): Failed to store result.
[21:01:48] [MySQL] Error (0): Function: mysql_fetch_field called when no result stored.
pawn Код:
if(dialogid == 35)
    {
       if(response)
       {

            if(!strlen(inputtext)) //If the player doesn't enter a pass
            {
                ShowPlayerDialog(playerid, 35, DIALOG_STYLE_PASSWORD , "Register", "This account is not registered, please register!", "OK", "Cancel");
                SendClientMessage(playerid, 0xF60000AA, "Please enter a password");
            }
            new field[256];
            new query[500];
            new escpname[24], escpass[100];
            mysql_real_escape_string(inputtext, escpass );
            mysql_real_escape_string(gPlayerInfo[playerid][pName], escpname);
            format(query, sizeof(query),"INSERT INTO `playerinfo` (`user`,`password`,`IP`,`date`) VALUES ('%s',%d,'%s',UTC_TIMESTAMP())",
            escpname,udb_hash(escpass),gPlayerInfo[playerid][pIp],gettime());
            mysql_query(query);
            mysql_store_result();
            format(query, sizeof(query),"SELECT `id` FROM `playerinfo` WHERE `user`='%s' LIMIT 1",escpname);
            mysql_fetch_int("id",gPlayerInfo[playerid][pDBID]);
            mysql_query(query);
            mysql_store_result();
            GameTextForPlayer(playerid,"~g~Registered",2000,3);
            SendClientMessage(playerid,0x0000D9AA,"Registered and Logged into your account!");
            gPlayerInfo[playerid][pLogged]=1;

        }

    }
i'm tired of this
can someone help me with this?
when i try to register the player only registre the date
and this cmd shows
pawn Код:
[21:01:48] [MySQL] Error (0): Failed to store result.
[21:01:48] [MySQL] Error (0): Function: mysql_fetch_field called when no result stored.
Reply
#2

Look at the commentary below, please.
Код:
mysql_query(query);
mysql_store_result();
format(query, sizeof(query),"SELECT `id` FROM `playerinfo` WHERE `user`='%s' LIMIT 1",escpname);
mysql_fetch_int("id",gPlayerInfo[playerid][pDBID]); //This expression wants to fetch the id of a query which wasn't sent at this moment, because the query will be sent not until the next line.
mysql_query(query);
mysql_store_result();
Do it like this:

Код:
mysql_query(query);
mysql_store_result();
format(query, sizeof(query),"SELECT `id` FROM `playerinfo` WHERE `user`='%s' LIMIT 1",escpname);
mysql_query(query);
mysql_store_result();
mysql_fetch_int("id",gPlayerInfo[playerid][pDBID]);
mysql_free_result();
And remove the mysql_store_result() line after the INSERT INTO query, it won't be needed.
Reply
#3

rep+ ty
Reply


Forum Jump:


Users browsing this thread: