SA-MP Forums Archive
MySQL: Commands out of sync; you can't run this command now) - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: MySQL: Commands out of sync; you can't run this command now) (/showthread.php?tid=196073)



MySQL: Commands out of sync; you can't run this command now) - armyoftwo - 04.12.2010

pawn Код:
stock ShowOfflineMessages(playerid)
{
    new  message[128];
    new  month[24];
    new  Date;
    new  CharacterIDs;
    new  mSQLID;
    new  Month;

    format(string, sizeof(string), "SELECT * FROM offline_messages WHERE SQLID = '%d'", AccountData[playerid][pSQLID]);
    mysql_query(string);
    //mysql_fetch_row_format(line,"|");

    while(mysql_fetch_row_format(line,"|")) {
        sscanf(line, "p<|>iis[128]ii", mSQLID, CharacterIDs , message, Month, Date);

        switch(Month) {
            case 1: month = "January";
            case 2: month = "February";
            case 3: month = "March";
            case 4: month = "April";
            case 5: month = "May";
            case 6: month = "June";
            case 7: month = "July";
            case 8: month = "August";
            case 9: month = "September";
            case 10: month = "October";
            case 11: month = "November";
            case 12: month = "December";
        }

        SendClientMessage(playerid, COLOR_WHITE, " ");
        SendFormattedMessage(playerid, COLOR_YELLOW, "[Offline Message:] Date: %i %s Message: %s", Date, month, message);

        format(string, sizeof(string), "DELETE FROM offline_messages WHERE SQLID = '%d' ", mSQLID);
        mysql_query(string);
    }
    mysql_free_result();
}



Re: MySQL: Commands out of sync; you can't run this command now) - xxmitsu - 04.12.2010

you must store result before fetching it.

pawn Код:
mysql_store_result();
And free the result before using another query.


Re: MySQL: Commands out of sync; you can't run this command now) - armyoftwo - 04.12.2010

Quote:
Originally Posted by xxmitsu
Посмотреть сообщение
you must store result before fetching it.

pawn Код:
mysql_store_result();
And free the result before using another query.
How could i forgot that?
Thanks