Problem to Load houses MYSQL
#1

hi,

I need to load my houses from mysql database

I have created the function to load the houses but she doesn't work

http://pastebin.com/q9n2D2FT
Reply
#2

Assuming LoadProperty callback is from the mysql function that executes the query, you only load the row 0.
pawn Код:
public LoadProperty()
{
    for (new idx = 0, rows = cache_get_row_count(); idx != rows; ++idx)
    {
        if (idx == sizeof (HouseInfo)) break;
        HouseInfo[idx][hEntrancex] = cache_get_field_content_float(idx, "hEntrancex");
        HouseInfo[idx][hEntrancey] = cache_get_field_content_float(idx, "hEntrancey");
        HouseInfo[idx][hEntrancez] =cache_get_field_content_float(idx, "hEntrancez");
        HouseInfo[idx][hExitx] = cache_get_field_content_float(idx, "hExitx");
        HouseInfo[idx][hExity] = cache_get_field_content_float(idx, "hExity");
        HouseInfo[idx][hExitz] = cache_get_field_content_float(idx, "hExitz");
        HouseInfo[idx][hHealthx] = cache_get_field_content_int(idx, "hHealthx");
        HouseInfo[idx][hHealthy] = cache_get_field_content_int(idx, "hHealthy");
        HouseInfo[idx][hHealthz] = cache_get_field_content_int(idx, "hHealthz");
        HouseInfo[idx][hArmourx] = cache_get_field_content_int(idx, "hArmourx");
        HouseInfo[idx][hArmoury] = cache_get_field_content_int(idx, "hArmoury");
        HouseInfo[idx][hArmourz] = cache_get_field_content_int(idx, "hArmourz");
        cache_get_field_content(idx, "hOwner", HouseInfo[idx][hOwner], 1, MAX_PLAYER_NAME);
        cache_get_field_content(idx, "hDiscription", HouseInfo[idx][hDiscription], 128);
        HouseInfo[idx][hValue] = cache_get_field_content_int(idx, "hValue");
        HouseInfo[idx][hHel] = cache_get_field_content_int(idx, "hHel");
        HouseInfo[idx][hArm] = cache_get_field_content_int(idx, "hArm");
        HouseInfo[idx][hInt] = cache_get_field_content_int(idx, "hInt");
        HouseInfo[idx][hLock] = cache_get_field_content_int(idx, "hLock");
        HouseInfo[idx][hOwned] = cache_get_field_content_int(idx, "hOwned");
        HouseInfo[idx][hRooms] =cache_get_field_content_int(idx, "hRooms");
        HouseInfo[idx][hRent] = cache_get_field_content_int(idx, "hRent");
        HouseInfo[idx][hRentabil] = cache_get_field_content_int(idx, "hRentabil");
        HouseInfo[idx][hTakings] = cache_get_field_content_int(idx, "hTakings");
        HouseInfo[idx][hDate] = cache_get_field_content_int(idx, "hDate");
        HouseInfo[idx][hLevel] = cache_get_field_content_int(idx, "hLevel");
        HouseInfo[idx][hWorld] = cache_get_field_content_int(idx, "hWorld");
        HouseInfo[idx][hSecurity] = cache_get_field_content_int(idx, "hSecurity");
        HouseInfo[idx][hCoffre] = cache_get_field_content_int(idx, "hCoffre");
        Create3DTextLabel(HouseInfo[idx][hDiscription],0xB40100FF, HouseInfo[idx][hEntrancex],HouseInfo[idx][hEntrancey],HouseInfo[idx][hEntrancez]+1,20,0);
        printf("HouseInfo:%d Owner:%s hTakings %d",idx,HouseInfo[idx][hOwner],HouseInfo[idx][hTakings]);
    }
}
Reply
#3

thanks but nothing :/
Reply
#4

Are you sure there're rows in the table? What does it print to the console/server log?
pawn Код:
new rows = cache_get_row_count();
printf("rows: %i", rows);
for (new idx; idx != rows; ++idx)
Reply
#5

pawn Код:
public LoadProperty()
{
    //I DONT KNOW YOUR 'MAX_HOUSES'
    new HouseInfo[MAX_HOUSES];
    for (new idx = 0, idx != cache_get_row_count() + 1; idx++)
    {
        HouseInfo[idx][hEntrancex] = cache_get_field_content_float(idx, "hEntrancex");
        HouseInfo[idx][hEntrancey] = cache_get_field_content_float(idx, "hEntrancey");
        HouseInfo[idx][hEntrancez] =cache_get_field_content_float(idx, "hEntrancez");
        HouseInfo[idx][hExitx] = cache_get_field_content_float(idx, "hExitx");
        HouseInfo[idx][hExity] = cache_get_field_content_float(idx, "hExity");
        HouseInfo[idx][hExitz] = cache_get_field_content_float(idx, "hExitz");
        HouseInfo[idx][hHealthx] = cache_get_field_content_int(idx, "hHealthx");
        HouseInfo[idx][hHealthy] = cache_get_field_content_int(idx, "hHealthy");
        HouseInfo[idx][hHealthz] = cache_get_field_content_int(idx, "hHealthz");
        HouseInfo[idx][hArmourx] = cache_get_field_content_int(idx, "hArmourx");
        HouseInfo[idx][hArmoury] = cache_get_field_content_int(idx, "hArmoury");
        HouseInfo[idx][hArmourz] = cache_get_field_content_int(idx, "hArmourz");
        cache_get_field_content(idx, "hOwner", HouseInfo[idx][hOwner], 1, MAX_PLAYER_NAME);
        cache_get_field_content(idx, "hDiscription", HouseInfo[idx][hDiscription], 128);
        HouseInfo[idx][hValue] = cache_get_field_content_int(idx, "hValue");
        HouseInfo[idx][hHel] = cache_get_field_content_int(idx, "hHel");
        HouseInfo[idx][hArm] = cache_get_field_content_int(idx, "hArm");
        HouseInfo[idx][hInt] = cache_get_field_content_int(idx, "hInt");
        HouseInfo[idx][hLock] = cache_get_field_content_int(idx, "hLock");
        HouseInfo[idx][hOwned] = cache_get_field_content_int(idx, "hOwned");
        HouseInfo[idx][hRooms] =cache_get_field_content_int(idx, "hRooms");
        HouseInfo[idx][hRent] = cache_get_field_content_int(idx, "hRent");
        HouseInfo[idx][hRentabil] = cache_get_field_content_int(idx, "hRentabil");
        HouseInfo[idx][hTakings] = cache_get_field_content_int(idx, "hTakings");
        HouseInfo[idx][hDate] = cache_get_field_content_int(idx, "hDate");
        HouseInfo[idx][hLevel] = cache_get_field_content_int(idx, "hLevel");
        HouseInfo[idx][hWorld] = cache_get_field_content_int(idx, "hWorld");
        HouseInfo[idx][hSecurity] = cache_get_field_content_int(idx, "hSecurity");
        HouseInfo[idx][hCoffre] = cache_get_field_content_int(idx, "hCoffre");
        Create3DTextLabel(HouseInfo[idx][hDiscription],0xB40100FF, HouseInfo[idx][hEntrancex],HouseInfo[idx][hEntrancey],HouseInfo[idx][hEntrancez]+1,20,0);
        printf("HouseInfo:%d Owner:%s hTakings %d",idx,HouseInfo[idx][hOwner],HouseInfo[idx][hTakings]);
    }
}
Look your mysql log file
Reply
#6

This is my public CreateHouse()

http://pastebin.com/QkeM6ehJ

and mysql

Reply
#7

up :/
Reply
#8

You showed a picture of updating a row only, not all the rows and the create is not the issue.

As I said:
Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Are you sure there're rows in the table? What does it print to the console/server log?
pawn Код:
new rows = cache_get_row_count();
printf("rows: %i", rows);
for (new idx; idx != rows; ++idx)
Reply
#9

nothing :/ , the printf : rows: 0
Reply
#10

It says that are 0 rows so it cannot retrieve any data since there are no rows. In case there are rows, then the query you executed is probably wrong so post it here.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)