Mysql Error: 1064 You have an error in your SQL syntax
#1

pawn Code:
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', WHERE groupID = '%d'", szLargeString, groupVariables[id][gSafePos][0], groupVariables[id][gSafePos][1], groupVariables[id][gSafePos][2], groupVariables[id][gGroupType], id );
        mysql_query(szLargeString);
    }
    else {
        return 0;
    }

    return 1;

}
And i'm getting

[21:06:22] 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 '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.760620', groupHQInteriorPosY = '-1749.291992', 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', WHERE groupID = '1'
Reply
#2

You had a comma before the final WHERE clause.
pawn Code:
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' WHERE groupID = '%d'", szLargeString, groupVariables[id][gSafePos][0], groupVariables[id][gSafePos][1], groupVariables[id][gSafePos][2], groupVariables[id][gGroupType], id );
        mysql_query(szLargeString);
    }
    return 1;
}
Reply
#3

Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)