SA-MP Forums Archive
MySql Not Saving - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySql Not Saving (/showthread.php?tid=349419)



MySql Not Saving - Robert_Crawford - 08.06.2012

Hey guy's i'm trying to add one variable to my faction table so i can save what map icon type they have. It says that it saves but it does not change in the table, no errors or warnings are shown.


My Stock For Saving
pawn Код:
stock saveGroup(const id) {
    if(strlen(groupVariables[id][gGroupName]) >= 1) {
        format(szLargeString, sizeof(szLargeString), "UPDATE groups SET groupName = '%s', groupHQExteriorPosX = '%f', groupHQExteriorPosY = '%f', groupHQExteriorPosZ = '%f'", groupVariables[id][gGroupName], groupVariables[id][gGroupExteriorPos][0], groupVariables[id][gGroupExteriorPos][1], groupVariables[id][gGroupExteriorPos][2]);
        format(szLargeString, sizeof(szLargeString), "%s, groupHQInteriorID = '%d', groupHQLockStatus = '%d', groupHQInteriorPosX = '%f', groupHQInteriorPosY = '%f', groupHQInteriorPosZ = '%f', groupSafeMoney = '%d', groupSafeMats = '%d', groupMOTD = '%s'", szLargeString, groupVariables[id][gGroupHQInteriorID],
        groupVariables[id][gGroupHQLockStatus], groupVariables[id][gGroupInteriorPos][0], groupVariables[id][gGroupInteriorPos][1], groupVariables[id][gGroupInteriorPos][2], groupVariables[id][gSafe][0], groupVariables[id][gSafe][1], groupVariables[id][gGroupMOTD]);
        format(szLargeString, sizeof(szLargeString), "%s, groupRankName1 = '%s', groupRankName2 = '%s', groupRankName3 = '%s', groupRankName4 = '%s', groupRankName5 = '%s', groupRankName6 = '%s'", szLargeString, groupVariables[id][gGroupRankName1], groupVariables[id][gGroupRankName2], groupVariables[id][gGroupRankName3], groupVariables[id][gGroupRankName4], groupVariables[id][gGroupRankName5], groupVariables[id][gGroupRankName6]);
        format(szLargeString, sizeof(szLargeString), "%s, groupSafePosX = '%f', groupSafePosY = '%f', groupSafePosZ = '%f', groupType = '%d' gMapIconID = '%d' WHERE groupID = '%d'", szLargeString, groupVariables[id][gSafePos][0], groupVariables[id][gSafePos][1], groupVariables[id][gSafePos][2], groupVariables[id][gGroupType], groupVariables[id][gMapIconID], id );
        mysql_query(szLargeString);
    }
    else {
        return 0;
    }

    return 1;

}
The Command
pawn Код:
CMD:gmapicon(playerid, params[]) {
    if(playerVariables[playerid][pAdminLevel] >= 4) {
        new
            groupID,
            groupMapIcon;

        if(sscanf(params, "dd", groupID, groupMapIcon))
            return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/gtype [groupid] [mapiconid]");

        if(groupID > 0 && groupID < MAX_GROUPS) {
            format(szMessage, sizeof(szMessage), "You have set group %s's group type to %d.", groupVariables[groupID][gGroupName], groupMapIcon);
            SendClientMessage(playerid, COLOR_WHITE, szMessage);

            groupVariables[groupID][gMapIconID] = groupMapIcon;
        } else return SendClientMessage(playerid, COLOR_GREY, "Invalid Group ID!");
    }
    return 1;
}
Command For Saving Tables
pawn Код:
CMD:savedata(playerid, params[]) {
    if(playerVariables[playerid][pAdminLevel] >= 5) {
        foreach(Player, x) {
            savePlayerData(x);
        }
        SendClientMessage(playerid, COLOR_YELLOW, "Player data saved.");

        for(new xh = 0; xh < MAX_HOUSES; xh++) {
            saveHouse(xh);
        }
        SendClientMessage(playerid, COLOR_YELLOW, "House data saved.");

        for(new xf = 0; xf < MAX_GROUPS; xf++) {
            saveGroup(xf);
        }
        SendClientMessage(playerid, COLOR_YELLOW, "Group data saved.");

        for(new xf = 0; xf < MAX_BUSINESSES; xf++) {
            saveBusiness(xf);
        }
        SendClientMessage(playerid, COLOR_YELLOW, "Business data saved.");

        for(new xf = 0; xf < MAX_ASSETS; xf++) {
            saveAsset(xf);
        }
        SendClientMessage(playerid, COLOR_YELLOW, "Server asset data saved.");
    }

    return 1;
}



Re: MySql Not Saving - Vince - 09.06.2012

I'm too tired to examine the entire query. Debug log?


Re: MySql Not Saving - Robert_Crawford - 09.06.2012

Код:
[19:23:48] [server] [cmd] Robert_Crawford (ID 0): /savedata
[19:23:48] errorid: 1064 | error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'gMapIconID = '1' WHERE groupID = '1'' at line 1 | resultid: -1 | extraid: -1 | callback: NULL | query: UPDATE groups SET groupName = 'Los Santos Police Department', groupHQExteriorPosX = '1555.498168', groupHQExteriorPosY = '-1675.593750', groupHQExteriorPosZ = '16.195299', groupHQInteriorID = '0', groupHQLockStatus = '0', groupHQInteriorPosX = '1474.158569', groupHQInteriorPosY = '-1750.073608', groupHQInteriorPosZ = '3285.285888', groupSafeMoney = '14549', groupSafeMats = '620', groupMOTD = 'Finally changed the LSPD motd!', groupRankName1 = 'Officer', groupRankName2 = 'Detective', groupRankName3 = 'Sergeant', groupRankName4 = 'Lieutenant', groupRankName5 = 'Captain', groupRankName6 = 'Chief', groupSafePosX = '226.471572', groupSafePosY = '124.153427', groupSafePosZ = '999.015625', groupType = '1' gMapIconID = '1' WHERE groupID = '1'
[19:23:48] errorid: 1064 | error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'gMapIconID = '0' WHERE groupID = '2'' at line 1 | resultid: -1 | extraid: -1 | callback: NULL | query: UPDATE groups SET groupName = 'Los Santos Fire & Medical Department', groupHQExteriorPosX = '1299.948608', groupHQExteriorPosY = '-1861.692504', groupHQExteriorPosZ = '13.546875', groupHQInteriorID = '17', groupHQLockStatus = '0', groupHQInteriorPosX = '378.026000', groupHQInteriorPosY = '-190.515502', groupHQInteriorPosZ = '1000.632812', groupSafeMoney = '0', groupSafeMats = '0', groupMOTD = '(null)', groupRankName1 = '(null)', groupRankName2 = '(null)', groupRankName3 = '(null)', groupRankName4 = '(null)', groupRankName5 = '(null)', groupRankName6 = '(null)', groupSafePosX = '0.000000', groupSafePosY = '0.000000', groupSafePosZ = '0.000000', groupType = '4' gMapIconID = '0' WHERE groupID = '2'
[19:23:48] errorid: 1064 | error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'gMapIconID = '1' WHERE groupID = '3'' at line 1 | resultid: -1 | extraid: -1 | callback: NULL | query: UPDATE groups SET groupName = 'The Agency', groupHQExteriorPosX = '2308.412109', groupHQExteriorPosY = '-1637.348022', groupHQExteriorPosZ = '14.827047', groupHQInteriorID = '6', groupHQLockStatus = '1', groupHQInteriorPosX = '316.232727', groupHQInteriorPosY = '-169.791290', groupHQInteriorPosZ = '999.601013', groupSafeMoney = '5000', groupSafeMats = '7150', groupMOTD = '(/setfrequency #1979)', groupRankName1 = 'potato', groupRankName2 = 'Prospect', groupRankName3 = 'Patch', groupRankName4 = 'Enforcer', groupRankName5 = 'Road Captain', groupRankName6 = 'President', groupSafePosX = '356.696594', groupSafePosY = '151.063232', groupSafePosZ = '1025.789062', groupType = '3' gMapIconID = '1' WHERE groupID = '3'
[19:23:48] errorid: 1064 | error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'gMapIconID = '0' WHERE groupID = '4'' at line 1 | resultid: -1 | extraid: -1 | callback: NULL | query: UPDATE groups SET groupName = 'San Andreas Goverment', groupHQExteriorPosX = '1481.016479', groupHQExteriorPosY = '-1771.215820', groupHQExteriorPosZ = '18.795755', groupHQInteriorID = '0', groupHQLockStatus = '0', groupHQInteriorPosX = '1056.516967', groupHQInteriorPosY = '-76.520011', groupHQInteriorPosZ = '1001.885925', groupSafeMoney = '12260', groupSafeMats = '0', groupMOTD = 'Leader-Lamont will be inactive till Monday have fun and RP till I am back.', groupRankName1 = 'Recruit', groupRankName2 = 'Hustler Loco', groupRankName3 = 'Huslter Loco', groupRankName4 = 'El Cholo', groupRankName5 = 'Lieutenant Governor', groupRankName6 = 'President', groupSafePosX = '368.132080', groupSafePosY = '162.652603', groupSafePosZ = '1008.382812', groupType = '2' gMapIconID = '0' WHERE groupID = '4'
[19:23:48] errorid: 1064 | error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'gMapIconID = '0' WHERE groupID = '5'' at line 1 | resultid: -1 | extraid: -1 | callback: NULL | query: UPDATE groups SET groupName = 'Federal Berua Of Investigation', groupHQExteriorPosX = '1653.644409', groupHQExteriorPosY = '-1655.367675', groupHQExteriorPosZ = '22.515625', groupHQInteriorID = '0', groupHQLockStatus = '1', groupHQInteriorPosX = '0.000000', groupHQInteriorPosY = '0.000000', groupHQInteriorPosZ = '0.000000', groupSafeMoney = '1', groupSafeMats = '1', groupMOTD = '(null)', groupRankName1 = '(null)', groupRankName2 = '(null)', groupRankName3 = '(null)', groupRankName4 = '(null)', groupRankName5 = '(null)', groupRankName6 = '(null)', groupSafePosX = '0.000000', groupSafePosY = '0.000000', groupSafePosZ = '0.000000', groupType = '1' gMapIconID = '0' WHERE groupID = '5'
[19:23:48] errorid: 1064 | error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'gMapIconID = '0' WHERE groupID = '6'' at line 1 | resultid: -1 | extraid: -1 | callback: NULL | query: UPDATE groups SET groupName = 'None', groupHQExteriorPosX = '0.000000', groupHQExteriorPosY = '0.000000', groupHQExteriorPosZ = '0.000000', groupHQInteriorID = '0', groupHQLockStatus = '1', groupHQInteriorPosX = '0.000000', groupHQInteriorPosY = '0.000000', groupHQInteriorPosZ = '0.000000', groupSafeMoney = '1', groupSafeMats = '1', groupMOTD = '(null)', groupRankName1 = '(null)', groupRankName2 = '(null)', groupRankName3 = '(null)', groupRankName4 = '(null)', groupRankName5 = '(null)', groupRankName6 = '(null)', groupSafePosX = '0.000000', groupSafePosY = '0.000000', groupSafePosZ = '0.000000', groupType = '0' gMapIconID = '0' WHERE groupID = '6'
[19:23:48] errorid: 1064 | error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'gMapIconID = '0' WHERE groupID = '7'' at line 1 | resultid: -1 | extraid: -1 | callback: NULL | query: UPDATE groups SET groupName = 'None', groupHQExteriorPosX = '0.000000', groupHQExteriorPosY = '0.000000', groupHQExteriorPosZ = '0.000000', groupHQInteriorID = '0', groupHQLockStatus = '1', groupHQInteriorPosX = '0.000000', groupHQInteriorPosY = '0.000000', groupHQInteriorPosZ = '0.000000', groupSafeMoney = '1', groupSafeMats = '1', groupMOTD = '(null)', groupRankName1 = '(null)', groupRankName2 = '(null)', groupRankName3 = '(null)', groupRankName4 = '(null)', groupRankName5 = '(null)', groupRankName6 = '(null)', groupSafePosX = '0.000000', groupSafePosY = '0.000000', groupSafePosZ = '0.000000', groupType = '0' gMapIconID = '0' WHERE groupID = '7'
[19:23:48] errorid: 1064 | error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'gMapIconID = '0' WHERE groupID = '8'' at line 1 | resultid: -1 | extraid: -1 | callback: NULL | query: UPDATE groups SET groupName = 'None', groupHQExteriorPosX = '0.000000', groupHQExteriorPosY = '0.000000', groupHQExteriorPosZ = '0.000000', groupHQInteriorID = '0', groupHQLockStatus = '1', groupHQInteriorPosX = '0.000000', groupHQInteriorPosY = '0.000000', groupHQInteriorPosZ = '0.000000', groupSafeMoney = '1', groupSafeMats = '1', groupMOTD = '(null)', groupRankName1 = '(null)', groupRankName2 = '(null)', groupRankName3 = '(null)', groupRankName4 = '(null)', groupRankName5 = '(null)', groupRankName6 = '(null)', groupSafePosX = '0.000000', groupSafePosY = '0.000000', groupSafePosZ = '0.000000', groupType = '0' gMapIconID = '0' WHERE groupID = '8'
[19:23:48] errorid: 1064 | error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'gMapIconID = '0' WHERE groupID = '9'' at line 1 | resultid: -1 | extraid: -1 | callback: NULL | query: UPDATE groups SET groupName = 'None', groupHQExteriorPosX = '0.000000', groupHQExteriorPosY = '0.000000', groupHQExteriorPosZ = '0.000000', groupHQInteriorID = '0', groupHQLockStatus = '1', groupHQInteriorPosX = '0.000000', groupHQInteriorPosY = '0.000000', groupHQInteriorPosZ = '0.000000', groupSafeMoney = '1', groupSafeMats = '1', groupMOTD = '(null)', groupRankName1 = '(null)', groupRankName2 = '(null)', groupRankName3 = '(null)', groupRankName4 = '(null)', groupRankName5 = '(null)', groupRankName6 = '(null)', groupSafePosX = '0.000000', groupSafePosY = '0.000000', groupSafePosZ = '0.000000', groupType = '0' gMapIconID = '0' WHERE groupID = '9'
[19:23:48] errorid: 1064 | error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'gMapIconID = '0' WHERE groupID = '10'' at line 1 | resultid: -1 | extraid: -1 | callback: NULL | query: UPDATE groups SET groupName = 'None', groupHQExteriorPosX = '0.000000', groupHQExteriorPosY = '0.000000', groupHQExteriorPosZ = '0.000000', groupHQInteriorID = '0', groupHQLockStatus = '1', groupHQInteriorPosX = '0.000000', groupHQInteriorPosY = '0.000000', groupHQInteriorPosZ = '0.000000', groupSafeMoney = '1', groupSafeMats = '1', groupMOTD = '(null)', groupRankName1 = '(null)', groupRankName2 = '(null)', groupRankName3 = '(null)', groupRankName4 = '(null)', groupRankName5 = '(null)', groupRankName6 = '(null)', groupSafePosX = '0.000000', groupSafePosY = '0.000000', groupSafePosZ = '0.000000', groupType = '0' gMapIconID = '0' WHERE groupID = '10'
[19:23:48] errorid: 1064 | error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'gMapIconID = '0' WHERE groupID = '11'' at line 1 | resultid: -1 | extraid: -1 | callback: NULL | query: UPDATE groups SET groupName = 'None', groupHQExteriorPosX = '0.000000', groupHQExteriorPosY = '0.000000', groupHQExteriorPosZ = '0.000000', groupHQInteriorID = '0', groupHQLockStatus = '1', groupHQInteriorPosX = '0.000000', groupHQInteriorPosY = '0.000000', groupHQInteriorPosZ = '0.000000', groupSafeMoney = '1', groupSafeMats = '1', groupMOTD = '(null)', groupRankName1 = '(null)', groupRankName2 = '(null)', groupRankName3 = '(null)', groupRankName4 = '(null)', groupRankName5 = '(null)', groupRankName6 = '(null)', groupSafePosX = '0.000000', groupSafePosY = '0.000000', groupSafePosZ = '0.000000', groupType = '0' gMapIconID = '0' WHERE groupID = '11'
[19:23:48] errorid: 1064 | error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's Auto Expo', businessOwner = 'Robert_Crawford', businessPrice = '0', businessVa' at line 1 | resultid: -1 | extraid: -1 | callback: NULL | query: UPDATE businesses SET businessExteriorX = '1616.466552', businessExteriorY = '-1897.085937', businessExteriorZ = '13.549173', businessInteriorX = '1404.112792', businessInteriorY = '7.681230', businessInteriorZ = '1000.906250', businessInterior = '1', businessType = '5', businessName = 'Robert's Auto Expo', businessOwner = 'Robert_Crawford', businessPrice = '0', businessVault = '120000', businessLock = '0', businessMiscX = '1612.360961', businessMiscY = '-1893.208007', businessMiscZ = '13.546875' WHERE businessID = '4'
I See One Line
Код:
19:23:48] errorid: 1064 | error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'gMapIconID = '0' WHERE groupID = '9'' at line 1



Re: MySql Not Saving - ReneG - 09.06.2012

Print the query, and post it. Hard to see what's going on under all that jumble.


Re: MySql Not Saving - Robert_Crawford - 09.06.2012

It's cool i forgot to add a comma

pawn Код:
, groupType = '%d' (, Here) gMapIconID = '%d' WHERE groupID = '%d'",
Sorry For Wasting Time