problem mysql
#1

hy im have a problem whit house mysql system don't work
pls help here is the line when i compile the gm dont give me error ori warning
sory for my bad englesh
pawn Код:
public LoadSQLProperty()
{
    new arrCoords[30][32];
    new sql[400], row[512];
    format(sql, sizeof(sql), "SELECT COUNT(*) FROM property");
    mysql_query(sql);
    //if (DEBUG) SQLLog(sql);
    mysql_store_result();
    mysql_fetch_row(row);
    totalhouses = strval(row);
    mysql_free_result();

    for (new idx=0; idx<totalhouses; idx++)
    {
        format(sql, sizeof(sql), "SELECT * FROM property WHERE id=%d", idx+1);
        mysql_query(sql);
        //if (DEBUG) SQLLog(sql);
        mysql_store_result();
        if (mysql_num_rows() > 0)
        {
            mysql_fetch_row_format(row, "|");
            explode(row, field, "|");
            mysql_free_result();
            HouseInfo[idx][hEntrancex] = floatstr(arrCoords[1]);
            HouseInfo[idx][hEntrancey] = floatstr(arrCoords[2]);
            HouseInfo[idx][hEntrancez] = floatstr(arrCoords[3]);
            HouseInfo[idx][hExitx] = floatstr(arrCoords[4]);
            HouseInfo[idx][hExity] = floatstr(arrCoords[5]);
            HouseInfo[idx][hExitz] = floatstr(arrCoords[6]);
            HouseInfo[idx][hHealthx] = strval(arrCoords[7]);
            HouseInfo[idx][hHealthy] = strval(arrCoords[8]);
            HouseInfo[idx][hHealthz] = strval(arrCoords[9]);
            HouseInfo[idx][hArmourx] = strval(arrCoords[10]);
            HouseInfo[idx][hArmoury] = strval(arrCoords[11]);
            HouseInfo[idx][hArmourz] = strval(arrCoords[12]);
            strmid(HouseInfo[idx][hOwner], arrCoords[13], 0, strlen(arrCoords[13]), 255);
            strmid(HouseInfo[idx][hDiscription], arrCoords[14], 0, strlen(arrCoords[14]), 255);
            HouseInfo[idx][hValue] = strval(arrCoords[15]);
            HouseInfo[idx][hHel] = strval(arrCoords[16]);
            HouseInfo[idx][hArm] = strval(arrCoords[17]);
            HouseInfo[idx][hInt] = strval(arrCoords[18]);
            HouseInfo[idx][hLock] = strval(arrCoords[19]);
            HouseInfo[idx][hOwned] = strval(arrCoords[20]);
            HouseInfo[idx][hRooms] = strval(arrCoords[21]);
            HouseInfo[idx][hRent] = strval(arrCoords[22]);
            HouseInfo[idx][hRentabil] = strval(arrCoords[23]);
            HouseInfo[idx][hTakings] = strval(arrCoords[24]);
            HouseInfo[idx][hVec] = strval(arrCoords[25]);
            if(HouseInfo[idx][hVec] == 457)
            {
                HouseInfo[idx][hVec] = 411;
            }
            HouseInfo[idx][hVcol1] = strval(arrCoords[26]);
            HouseInfo[idx][hVcol2] = strval(arrCoords[27]);
            HouseInfo[idx][hDate] = strval(arrCoords[28]);
            HouseInfo[idx][hLevel] = strval(arrCoords[29]);
            printf("HouseInfo:%d Owner:%s hTakings %d hVec %d",idx,HouseInfo[idx][hOwner],HouseInfo[idx][hTakings],HouseInfo[idx][hVec]);
        }
    }
    return 1;
}
Reply
#2

Oh no, please no ...
* Vince cries in a corner.

I have told this to several people already, but this is THE ABSOLUTE WORST way to load multiple rows from the database.

pawn Код:
public LoadSQLProperty()
{
    mysql_query("SELECT * FROM property");
    mysql_store_result();

    new row[512], idx;

    while(mysql_fetch_row_format(row, "|"))
    {
        // Use sscanf/split/explode here to fetch data from current row
        // NO mysql_free_result inside this loop!

        idx++;
    }

    mysql_free_result();
    return 1;
}
This is all you'll ever need.
Reply
#3

pls 1 example here
pawn Код:
while(mysql_fetch_row_format(row, "|"))
    {
        // Use sscanf/split/explode here to fetch data from current row
        // NO mysql_free_result inside this loop!

        idx++;
    }
Reply
#4

How do you expect to set up a server or make a script or whatever, if you do NOT know how to use the simplest codes?
Reply
#5

i need onle 1 example not all script
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)