[MYSQL]Getting all rows from a table
#1

To fix the problem: http://pastebin.com/RPKQzz0j

________________________________________________

I am currently trying to rebuild a Housing system.
The system works very well except for 1 thing.
On filterscriptinit should load all the houses at once, then create them 1 by 1.

I have no clue on what to do on this issue, reading a table to expect only 1 row i know by heart, receiving multiple rows, there i am lost.

This is what i've got, it seems to read only 1 row:

>>> ERROR MESSAGE:
[14:44:55] Filterscript 'housesystem.amx' loaded.
[14:44:55] [MySQL] Error (0): Function: mysql_store_result called when no result stored.
[14:44:55] Number of created Houses: 1


>>> PASTEBIN VERSION: http://pastebin.com/ADCHrZfc

pawn Код:
#define THREAD_LOADHOUSES               100

public OnFilterScriptInit()
{
    //MySQL Connection
    MySQLConnect(MySQL_Hostname, MySQL_Username, MySQL_Database, MySQL_Password, MySQL_Connection, true);
   
    //Load Houses
    mysql_query("SELECT * FROM `houses`", THREAD_LOADHOUSES, -1);
    return 1;
}



public OnMysqlQuery(resultid, spareid, MySQL:handle)
{
    switch(resultid)
    {
        case THREAD_LOADHOUSES:
        {
            mysql_store_result(handle);
            new HouseCount = 0, MySQL_Load[150];
            while(mysql_fetch_row(MySQL_Load, "|", handle))
            {
                new ID, Owner[24], HName[128], HPass[128], Float:X, Float:Y, Float:Z, Float:eX, Float:eY, Float:eZ, Float:eA, Doors, InteriorModel, Cost;
                sscanf(MySQL_Load, "p<|>ds[24]s[128]s[128]fffffffddd",
                ID,
                Owner,
                HName,
                HPass,
                X,
                Y,
                Z,
                eX,
                eY,
                eZ,
                eA,
                Doors,
                InteriorModel,
                Cost);

                CreateHouse(true, ID, Owner, HName, HPass, X, Y, Z, eX, eY, eZ, eA, Doors, InteriorModel, Cost);
                HouseCount ++;
            }
            printf("Number of created Houses: %d", HouseCount);

            mysql_free_result(handle);
        }
    }
    return 1;
}
Reply


Messages In This Thread
[MYSQL][FIXED]Getting all rows from a table - by Webghost - 30.10.2011, 13:50
Re: [MYSQL]Getting all rows from a table - by Webghost - 30.10.2011, 16:05
Re: [MYSQL]Getting all rows from a table - by skullmuncher1337 - 30.10.2011, 16:07
Re: [MYSQL]Getting all rows from a table - by Webghost - 30.10.2011, 19:23
Re: [MYSQL]Getting all rows from a table - by Joe Staff - 30.10.2011, 21:12
Re: [MYSQL]Getting all rows from a table - by Webghost - 31.10.2011, 16:30
Re: [MYSQL]Getting all rows from a table - by Webghost - 31.10.2011, 16:40
Re: [MYSQL]Getting all rows from a table - by Treyvan - 31.10.2011, 17:49

Forum Jump:


Users browsing this thread: 2 Guest(s)