Server is Counting wrong amount of Houses from MySQL.
#1

pawn Код:
stock LoadHouses()
{
    new QueryString[128];
    mysql_query( "SELECT * FROM houses");
    mysql_store_result();
    new x;
    while(mysql_retrieve_row())
    {
            mysql_get_field( "id", QueryString);
            x = strval( QueryString);
           
            mysql_get_field("HouseName", HouseName[x]);

            mysql_get_field("HouseOwner", HouseOwner[x]);
           
            mysql_get_field( "HouseEntX", QueryString);
            HouseEntX[x] = floatstr( QueryString);

            mysql_get_field( "HouseEntY", QueryString);
            HouseEntY[x] = floatstr( QueryString);

            mysql_get_field( "HouseEntZ", QueryString);
            HouseEntZ[x] = floatstr( QueryString);

            mysql_get_field( "HouseIntX", QueryString);
            HouseIntX[x] = floatstr( QueryString);

            mysql_get_field( "HouseIntY", QueryString);
            HouseIntY[x] = floatstr( QueryString);

            mysql_get_field( "HouseIntZ", QueryString);
            HouseIntZ[x] = floatstr( QueryString);

            mysql_get_field( "HouseInt", QueryString);
            HouseInt[x] = strval( QueryString);
           
            mysql_get_field( "HouseVW", QueryString);
            HouseVW[x] = strval( QueryString);

            mysql_get_field( "HouseWS1", QueryString);
            HouseWS1[x] = strval( QueryString);

            mysql_get_field( "HouseWA1", QueryString);
            HouseWA1[x] = strval( QueryString);

            mysql_get_field( "HouseWS2", QueryString);
            HouseWS2[x] = strval( QueryString);

            mysql_get_field( "HouseWA2", QueryString);
            HouseWA2[x] = strval( QueryString);

            mysql_get_field( "HouseWS3", QueryString);
            HouseWS3[x] = strval( QueryString);

            mysql_get_field( "HouseWA3", QueryString);
            HouseWA3[x] = strval( QueryString);

            mysql_get_field( "HouseMoney", QueryString);
            HouseMoney[x] = strval( QueryString);

            mysql_get_field( "HouseCoke", QueryString);
            HouseCoke[x] = strval( QueryString);

            mysql_get_field( "HouseWeed", QueryString);
            HouseWeed[x] = strval( QueryString);
           
            mysql_get_field( "HouseArmour", QueryString);
            HouseArmour[x] = floatstr( QueryString);

            mysql_get_field( "HousePrice", QueryString);
            HousePrice[x] = strval( QueryString);

            mysql_get_field( "HouseLock", QueryString);
            HouseLock[x] = strval( QueryString);
           
            mysql_get_field( "ForSale", QueryString);
            ForSale[x] = strval( QueryString);
           
            HousePickup[x] = CreateDynamicPickup(1273, 23, HouseEntX[x], HouseEntY[x], HouseEntZ[x], 0);
            CreateDynamic3DTextLabel(HouseName[x], COLOUR_LIGHTBLUE, HouseEntX[x],HouseEntY[x], HouseEntZ[x], 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, 0, -1, -1, 50.0);

            x++;
    }
    printf("HOUSES LOADED: %d",x);
    mysql_free_result();
    return 1;
}
I do the x++; in every single thing I load, for some reason it's saying there is 22 Houses loaded, although I only have 21 Displayed on the MySQL table.

I have made sure I can view 50 records on Php.
Reply
#2

pawn Код:
printf("HOUSES LOADED: %d",mysql_num_rows());
x = strval( QueryString); gets the house id, and x ++; increments x meaning you'll get one more.
Reply
#3

Since you're not using a while(x < BLABLA) statement, there is no need for the x++; at the end of the while(mysql_retrieve_row()) statement.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)