Why is this not loading MySQL data into the variables properly?
#1

pawn Код:
stock LoadHouses()
{
    mysql_function_query(g_Handle, "SELECT * FROM `Houses`", true, "HousesLoad", "");
    return 1;
}
pawn Код:
public HousesLoad()
{
    new temp[400], string[400], rows, fields;
    cache_get_data(rows, fields, g_Handle);

    if(rows)
    {
        for(new id = 0; id < rows; id++)
        {
            cache_get_row(0, 0, temp, g_Handle), HouseInfo[id][hHouseID] = strval(temp);
            cache_get_row(0, 1, temp, g_Handle), HouseInfo[id][hAddress] = strval(temp);
            cache_get_row(0, 2, temp, g_Handle), HouseInfo[id][hPrice] = strval(temp);
            cache_get_row(0, 3, temp, g_Handle), HouseInfo[id][hEnterPos][0] = floatstr(temp);
            cache_get_row(0, 4, temp, g_Handle), HouseInfo[id][hEnterPos][1] = floatstr(temp);
            cache_get_row(0, 5, temp, g_Handle), HouseInfo[id][hEnterPos][2] = floatstr(temp);
            cache_get_row(0, 6, temp, g_Handle), HouseInfo[id][hExitPos][0] = floatstr(temp);
            cache_get_row(0, 7, temp, g_Handle), HouseInfo[id][hExitPos][1] = floatstr(temp);
            cache_get_row(0, 8, temp, g_Handle), HouseInfo[id][hExitPos][2] = floatstr(temp);

            HouseInfo[id][hPickup] = CreateDynamicPickup(1273, 23, HouseInfo[id][hEnterPos][0], HouseInfo[id][hEnterPos][1], HouseInfo[id][hEnterPos][2], -1, -1, -1, 100.0);
            format(string,sizeof(string),"HouseID: %d\nAddress: %s\nPrice: %d", HouseInfo[id][hHouseID], HouseInfo[id][hAddress], HouseInfo[id][hPrice]);
            HouseInfo[id][hText] = CreateDynamic3DTextLabel(string, -1, HouseInfo[id][hEnterPos][0], HouseInfo[id][hEnterPos][1], HouseInfo[id][hEnterPos][2], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100);
            break;
        }
        printf("%i houses loaded.", rows);
    }
    return 1;
}
It loads the rows from the MySQL database and adds the pickups and text labels, but the address information from the text labels are blank?

If I do this in the loop, it says "0 houses."... Been stuck on this for days, doesn't make sense to me.

pawn Код:
printf("%i houses.", id);
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)