[++Rep] SQLlite code question
#5

With this code :

pawn Code:
else if(db_num_rows(Result)) // The house ID is in the database. Update the values
    {
   
        for(new i = 0; i <= MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                SendClientMessage(i, -1, "The house was found in database! Updating..");
            }
        }
        new string[256];
        format(string, sizeof(string), "Failstep 1 : House owner : %s and house owned %d", AHouseData[HouseID][Owner], AHouseData[HouseID][Owned]);
        print(string);

        strcat(HouseStrCat, "UPDATE `Houses` SET `HouseAddress` = '%s', `HouseName` = '%s', `HouseX` = '%f', `HouseY` = '%f', `HouseZ` = '%f', `HouseInterior` = '%d', `HouseMaxSlots` = '%d', `HouseNewMaxSlots` = '%d', `HousePrice` = '%d', `Owned` = '%d', `HouseOpened` = '%d', ", sizeof(HouseStrCat)); // 11
        strcat(HouseStrCat, "`PlayerIsTycoon` = '%d', `Owner` = '%s', `Insurance` = '%d' WHERE `HouseID` = '%d'", sizeof(HouseStrCat)); // 15
        format(Query, sizeof(Query), HouseStrCat, AHouseData[HouseID][HouseAddress], AHouseData[HouseID][HouseName], AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ], AHouseData[HouseID][HouseInterior], AHouseData[HouseID][HouseMaxSlots], AHouseData[HouseID][HouseNewMaxSlots], AHouseData[HouseID][HousePrice], AHouseData[HouseID][Owned],
        AHouseData[HouseID][HouseOpened], AHouseData[HouseID][PlayerIsTycoon], AHouseData[HouseID][Owner], AHouseData[HouseID][Insurance], HouseID); // 15
        db_query(Database, Query);
       
        strdel(HouseStrCat, 0, 800);

        format(Query, sizeof(Query), "SELECT * FROM `Houses` WHERE `HouseID` = '%d'", HouseID);
        Result2 = db_query(Database,Query);

        new ParameterValue[50], ParameterValue2[50];
        db_get_field_assoc(Result2, "Owned", ParameterValue, 50);
        db_get_field_assoc(Result2, "Owner", ParameterValue2, 50);

        format(string, sizeof(string), "Failstep 1 : House owner : %s and house owned %d", ParameterValue2, ParameterValue);
        print(string);





        for(new i = 0; i <= MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                SendClientMessage(i, -1, "Updated!");
            }
        }

    }
The failsteps return these messages:

Code:
[17:07:46] Kulottaja used: /buyhouse 
[17:07:46] Failstep 1 : House owner : Kulottaja and house owned 1
[17:07:46] Failstep 1 : House owner :  and house owned 48
The first failstep message (format(string, sizeof(string), "Failstep 1 : House owner : %s and house owned %d", AHouseData[HouseID][Owner], AHouseData[HouseID][Owned])

Returned the correct values as you could see (Kulottaja and house owned returned 1)

But then then it was saved, i load the 2 values from the database just to check if they are correct, and there is still the problem. The owner of house is not "" and it returns value 48 at house owned...


I got no idea anymore, but maybe a db_free_result issue?
Reply


Messages In This Thread
[++Rep] SQLlite code question - by Hessu - 02.10.2015, 05:25
Re: [++Rep] SQLlite code question - by Mowgli - 02.10.2015, 09:11
Re: [++Rep] SQLlite code question - by Mowgli - 02.10.2015, 09:15
Re: [++Rep] SQLlite code question - by Hessu - 02.10.2015, 11:19
Re: [++Rep] SQLlite code question - by Hessu - 02.10.2015, 14:11
Re: [++Rep] SQLlite code question - by Pottus - 02.10.2015, 15:09
Re: [++Rep] SQLlite code question - by Hessu - 03.10.2015, 05:00

Forum Jump:


Users browsing this thread: 2 Guest(s)