Issues deleteing from MySQL database.
#1

So the issue is that in the buildings database it is deleting the buildings but not in the right order and in the business database it isn't even deleting them.

Code:
case DestroyBuildingID:
		{
  			if(!response) {
				return 1;
		    }
			else {
				if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DestroyBuildingID, DIALOG_STYLE_INPUT, "Destroy buildings", "Please enter the ID of the building you would like\nto destroy.", "Accept", "Close");
    			if(strlen(inputtext) >= 7) return ShowPlayerDialog(playerid, DestroyBuildingID, DIALOG_STYLE_INPUT, "Destroy buildings", "Please enter the ID of the building you would like\nto destroy.", "Accept", "Close");
       			new amount = strval(inputtext);
          		if(amount >= 99999999) return ShowPlayerDialog(playerid, DestroyBuildingID, DIALOG_STYLE_INPUT, "Destroy buildings", "Please enter the ID of the building you would like\nto destroy.", "Accept", "Close");
            	new id = BuildingExists(amount);
             	if(id >= 0)
              	{
              		IDforEditing[playerid] = amount;
               		SetPVarInt(playerid, "DestroyType", 1);
                	new String[256], String2[256];
		    		format(String, sizeof(String), "Destroying: %s (ID: %d)", BuildingInfo[IDforEditing[playerid]][Name], IDforEditing[playerid]);
			    	format(String2, sizeof(String2), "You are about to destroy building %s ID: %d, Are you sure about this?", BuildingInfo[IDforEditing[playerid]][Name], IDforEditing[playerid]);
			    	ShowPlayerDialog(playerid, DestroyBuildingConfirm, DIALOG_STYLE_MSGBOX, String, String2, "Yes", "No");
				}
				else if(id == -1) return SCM(playerid, COLOR_ORANGE, "Server: That building wasn't found in our database.");
			}
		}
		case DestroyBuildingConfirm:
		{
  			if(!response) {
  			    SetPVarInt(playerid, "DestroyType", 0);
				return 1;
		    }
			else {
			    DestroyDynamic3DTextLabel(Build3D[IDforEditing[playerid]]);
				DestroyDynamicPickup(BuildPickup[IDforEditing[playerid]]);
				new query[128];
		    	mysql_format(mysql, query, sizeof(query), "DELETE FROM `buildings` WHERE `ID` = %d", BuildingInfo[IDforEditing[playerid]][ID]);
				mysql_pquery(mysql, query);
				new String[256];
				new pName[24];
				GetPlayerName(playerid, pName, 24);
   				GiveNameSpace(pName);
				format(String, sizeof(String), "Server: %s destroyed building %s (ID: %d)", pName, BuildingInfo[IDforEditing[playerid]][Name] ,IDforEditing[playerid]);
				SendAdminMessage(COLOR_ORANGE, String);
				BuildingInfo[IDforEditing[playerid]][ID] = 0;
				BuildingInfo[IDforEditing[playerid]][EnterX] = 0.0;
				SetPVarInt(playerid, "DestroyType", 0);
			}
		}
		case DestroyBusinessID:
		{
  			if(!response) {
				return 1;
		    }
			else {
				if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DestroyBusinessID, DIALOG_STYLE_INPUT, "Destroy Businesses", "Please enter the ID of the Businesses you would like\nto destroy.", "Accept", "Close");
    			if(strlen(inputtext) >= 7) return ShowPlayerDialog(playerid, DestroyBusinessID, DIALOG_STYLE_INPUT, "Destroy Businesses", "Please enter the ID of the Businesses you would like\nto destroy.", "Accept", "Close");
       			new amount = strval(inputtext);
          		if(amount >= 99999999) return ShowPlayerDialog(playerid, DestroyBusinessID, DIALOG_STYLE_INPUT, "Destroy Businesses", "Please enter the ID of the Businesses you would like\nto destroy.", "Accept", "Close");
            	new id = BusinessesExists(amount);
             	if(id >= 0)
              	{
              		IDforEditing[playerid] = amount;
               		SetPVarInt(playerid, "DestroyType", 1);
               		new String[256], String2[256];
		    		format(String, sizeof(String), "Destroying: %s (ID: %d)", BusinessInfo[IDforEditing[playerid]][Name], IDforEditing[playerid]);
			    	format(String2, sizeof(String2), "You are about to destroy Business %s ID: %d, Are you sure about this?", BusinessInfo[IDforEditing[playerid]][Name], IDforEditing[playerid]);
			    	ShowPlayerDialog(playerid, DestroyBusinessConfirm, DIALOG_STYLE_MSGBOX, String, String2, "Yes", "No");
				}
				else if(id == -1) return SCM(playerid, COLOR_ORANGE, "Server: That Business wasn't found in our database.");
			}
		}
		case DestroyBusinessConfirm:
		{
  			if(!response) {
  			    SetPVarInt(playerid, "DestroyType", 0);
				return 1;
		    }
			else {
			    DestroyDynamic3DTextLabel(Business3D[IDforEditing[playerid]]);
				DestroyDynamicPickup(BusinessPickup[IDforEditing[playerid]]);
				new query[128];
		    	mysql_format(mysql, query, sizeof(query), "DELETE FROM `businesses` WHERE `ID` = %d", BusinessInfo[IDforEditing[playerid]][ID]);
				mysql_pquery(mysql, query);
				new String[256];
				new pName[24];
				GetPlayerName(playerid, pName, 24);
   				GiveNameSpace(pName);
				format(String, sizeof(String), "Server: %s destroyed Business %s (ID: %d)", pName, BusinessInfo[IDforEditing[playerid]][Name] ,IDforEditing[playerid]);
				SendAdminMessage(COLOR_ORANGE, String);
				BusinessInfo[IDforEditing[playerid]][ID] = 0;
				BusinessInfo[IDforEditing[playerid]][EnterX] = 0.0;
				SetPVarInt(playerid, "DestroyType", 0);
			}
		}
Table Structures.


Code:
CREATE TABLE `buildings` (
  `ID` int(10) NOT NULL,
  `Name` varchar(256) NOT NULL,
  `Interior` int(10) NOT NULL,
  `VirtualWorld` int(10) NOT NULL,
  `EnterX` float NOT NULL,
  `EnterY` float NOT NULL,
  `EnterZ` float NOT NULL,
  `ExitX` float NOT NULL,
  `ExitY` float NOT NULL,
  `ExitZ` float NOT NULL,
  `FreezeTimer` int(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `businesses`
--

CREATE TABLE `businesses` (
  `ID` int(10) NOT NULL,
  `Name` varchar(256) NOT NULL,
  `Interior` int(10) NOT NULL,
  `VirtualWorld` int(10) NOT NULL,
  `Type` int(10) NOT NULL,
  `Price` int(11) NOT NULL,
  `Balance` int(10) NOT NULL,
  `Locked` int(10) NOT NULL,
  `EnterX` float NOT NULL,
  `EnterY` float NOT NULL,
  `EnterZ` float NOT NULL,
  `ExitX` float NOT NULL,
  `ExitY` float NOT NULL,
  `ExitZ` float NOT NULL,
  `FreezeTimer` int(10) NOT NULL,
  `FurnAmount` int(11) NOT NULL,
  `Owner` varchar(25) NOT NULL,
  `Owned` int(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Indexes for table `buildings`
--
ALTER TABLE `buildings`
  ADD PRIMARY KEY (`ID`);

--
-- Indexes for table `businesses`
--
ALTER TABLE `businesses`
  ADD PRIMARY KEY (`ID`);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)