Help with Query Failed?

Hello everyone,
Firstly I would like to say that this error is with the PERP gamemode. Before you start badmouthing etc and talking about how overdone it is, I’m not making a PERP server. I just simply want to fix the code to help me get better at lua. Currently, these issues that have come up I have had no idea how to fix though. The first one is to do with mysql I’m pretty sure, and the second one is to do with the Property etc.

First issue (Mysql):
Everytime someone tries to join for me to test certain elements, the game spits out this in console http://puu.sh/6AaHs.png and states that it couldn’t insert the data into the sql tables. However, if I add all the details that are displayed manually, the user can join with no trouble. I’m unsure of whether this is lua code related or mysql related. If someone tells me the name of the file that is causing this error, I will post the code.

Second issue(Property):
When I purchase property, it takes away money but when I click it again, the menu still comes up with purchase. It doesn’t say sell or that the property has been sold. Unsure of how to fix this. http://puu.sh/6B3JB.jpg (Stays like this after buying)

Any help would be appreciated as I’m trying to get better at lua.
Thanks

  1. Go search through all the files in the perp gamemode for the “INSERT INTO …” and show me what you find.

  2. There’s no way we can help you fix that without more information.

Hey there,
These are the files I found.

sv_warehouse (This one I just havent made a table for, perp runs fine without it.)



function PLAYER:SaveWarehouse()
	local strSteamID = self:SteamID()
	for iItem, iAmount in pairs(self.PlayerWarehouse) do
		if(iAmount < 1) then
			DataBase:Query("DELETE FROM `perp_warehouse` WHERE `steamid`='" ..strSteamID.. "' AND `itemid`='" ..iItem.. "'")
		else
			DataBase:Query("SELECT * FROM `perp_warehouse` WHERE `steamid`='" ..strSteamID.. "' AND `itemid`='" ..iItem.. "'", function( tbl )
				if(#tbl == 0) then
					DataBase:Query("INSERT INTO `perp_warehouse` (`steamid`, `itemid`, `amount`) VALUES('" ..strSteamID.. "', '" ..iItem.. "', '" ..iAmount.. "')")
				else
					DataBase:Query("UPDATE `perp_warehouse` SET `amount`='" ..iAmount.. "' WHERE `steamid`='" ..strSteamID.. "' AND `itemid`='" ..iItem.. "'")
				end
			end )
		end
	end
end


sv_organisations



function GM.NewOrganization ( Player )
	if (Player:GetCash() < 5000) then return; end
	Player:TakeCash(5000);
	
	DataBase:Query("INSERT INTO `perp_organization` (`name`, `motd`, `owner`) VALUES ('New Organization', 'No Current MOTD', '" .. Player.SMFID .. "')", function ( d )
		DataBase:Query("SELECT `id` FROM `perp_organization` WHERE `owner`='" .. Player.SMFID .. "' LIMIT 1", function ( data ) 
			if (data[1] && data[1][1]) then
				Player:SetSharedInt("org", tonumber(data[1][1]));
				DataBase:Query("UPDATE `perp_users` SET `organization`='" .. data[1][1] .. "' WHERE `id`='" .. Player.SMFID .. "' LIMIT 1");
				GAMEMODE.FetchOrganizationData(tonumber(data[1][1]))
			end
		end);
	end);
end
concommand.Add("perp_o_n", GM.NewOrganization);


sv_networking



DataBase:Query("SELECT `id`, `rp_name_first`, `rp_name_last`, `time_played`, `cash`, `model`, `items`, `skills`, `genes`, `formulas`, `organization`, `bank`, `vehicles`, `blacklists`, `ringtone`, `ammo_pistol`, `ammo_rifle`, `ammo_shotgun`, `fuelleft`, `lastcar` FROM `perp_users` WHERE `id`='" .. Player.SMFID .. "'", function ( PlayerInfo )
		if (!Player || !Player:IsValid() || !IsValid(Player)) then return end
				
		if (!PlayerInfo || !PlayerInfo[1]) then
			DataBase:Query("INSERT INTO `perp_users` (`id`, `uid`, `steamid`, `rp_name_first`, `rp_name_last`, `genes`, `cash`, `blacklists`, `model`, `items`, `skills`, `formulas`, `organization`, `bank`, `vehicles`, `ringtones`, `ringtone`, `time_played`, `last_played`) VALUES ('" .. Player.SMFID .. "', '" .. Player:UniqueID() .. "', '" .. Player:Nick() .. "', 'John', 'Doe', '5', '15000', '', '', '', '', '', '0', '0', '0', '', '1', '0', '0')", function (...)
			PrintTable({...})
			DataBase:Query("INSERT INTO `perp_fuel` (`uid`) VALUES ('" .. Player:UniqueID() .. "')");
				if (!Player || !Player:IsValid() || !IsValid(Player)) then return end
				
				Player.CanSetupPlayer = true;
				timer.Simple(1, function()
					GAMEMODE.LoadPlayerProfile(Player); end)
			end);
			return;
		else
			DataBase:Query("UPDATE `perp_users` SET `steamid`='" .. Player:Nick() .. "' WHERE `id`='" .. Player.SMFID .. "'");
		end
		if (PlayerInfo[1][2] == "John" && PlayerInfo[1][3] == "Doe") then Player.CanSetupPlayer = true; end
		
		if (Player.CanSetupPlayer) then
			Msg("Allowing " .. Player:Nick() .. " to setup new player...
");
			umsg.Start("perp_newchar", Player);
			umsg.End();
		else
			Player:DetectBaconBot();
		end


This is all I can find. Thanks for your help

Update:
I replaced all the Database:Query with tmysql.query with help from a friend on steam but still no luck. People are only able to join if I add all the data on sv_networking manually to the mysql.