SA-MP Forums Archive
Mysql errors - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Mysql errors (/showthread.php?tid=572933)



Mysql errors - RafaelZam - 03.05.2015

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.



AW: Mysql errors - JackBauer1994 - 03.05.2015

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.


Respuesta: Mysql errors - RafaelZam - 03.05.2015

rep+ ty