Jump to content

Fatal Error Help.


netpants

Recommended Posts

Hey I am trying to include one file into another and am getting this error while trying to run the php file.

 

Bank
You successfully upgraded your Moat Level.
Fatal error: Call to a member function on a non-object in /home/gamesite/domains/mygamespot.net/public_html/battle/play/upgradeMoat.php on line 97

 

Here is the code for the file I am including into.[upgrade.php]

 

<?


$isadmin="*";
include("../includes/inc-header.php");

if($user['uMineLevel']==1){
$price = 2500000;
}
elseif($user['uMineLevel']==2){
$price = 7500000;
}
elseif($user['uMineLevel']==3){
$price = 22500000;
}
elseif($user['uMineLevel']==4){
$price = 67500000;
}
elseif($user['uMineLevel']==5){
$price = "-";
$isupgrades = 1;
}
if($user['uMineLevel']!=5){
$nextlevel = $user['uMineLevel']+1;
}
if(!$_POST['mine']){
if(!$isupgrades){
	?>
-------------------------------INCLUDED RIGHT HERE-----------------------
<?
include("upgradeMoat.php");
?>
---------------------------------------------------------------
	<form action="upgrade.php" method="post">
	<?
}
?>
<table width="100%"  border="0">
  <tr>
	<td colspan="3" class="bodycell3">Upgrades</td>
  </tr>
  <tr>
	<td class="bodycell5" align="center" width="30%">
	<b>Mine Level</b>
	</td>
	<td class="bodycell5" align="center" width="40%">
	<?=$price?>
	</td>
	<td class="bodycell5" align="center" width="30%">
	<?
	if($user['uMineLevel']!=5){
		?>
		<input name="mine" type="submit" value="Upgrade to Level <?=$nextlevel?>">
		<?
	}
	else{
		echo "-";
	}
	?>
	</td>
  </tr>
</table>

<?
if(!$isupgrades){
	?>
	</form>
	<?
}
}
elseif($_POST['mine']){
?>
<table width="100%"  border="0">
  <tr>
	<td class="bodycell3">Bank</td>
  </tr>
  <tr>
	<td class="bodycell4" align="center">
	<?
	if($nextlevel=="-"){
		echo "There are no further upgrades for this.";
	}
	elseif($price>$user['uGold']){
		echo "You don't have enough gold to upgrade.";
	}
	else{
		echo "You successfully upgraded your Mine Level.";
		$db->query("UPDATE users SET uGold=uGold-$price,uMineLevel=$nextlevel WHERE uID='" . $user['uID'] . "'");
	}
	?>
	<br><br>
	<a href="javascript:history.back();">BACK</a>
	</td>
  </tr>
</table>
<?
}
include("../includes/inc-footer.php");
?>

 

 

Here is the script in the file I included in the above file above. [upgradeMoat.php]

 

<?



$isadmin="*";



if($user['uMoatLevel']==1){
$Mprice = 2500000;
}
elseif($user['uMoatLevel']==2){
$Mprice = 7500000;
}
elseif($user['uMoatLevel']==3){
$Mprice = 22500000;
}
elseif($user['uMoatLevel']==4){
$Mprice = 67500000;
}
elseif($user['uMoatLevel']==5){
$Mprice = "-";
$Misupgrades = 1;
}
if($user['uMoatLevel']!=5){
$Mnextlevel = $user['uMoatLevel']+1;
}
if(!$_POST['moat']){
if(!$Misupgrades){
	?>
	<form action="upgradeMoat.php" method="post">
	<?
}
?>
<table width="100%"  border="0">
  <tr>
	<td colspan="3" class="bodycell3">Defense Upgrades</td>
  </tr>
  <tr>
	<td class="bodycell5" align="center" width="30%">
	<b>Moat Level</b>
	</td>
	<td class="bodycell5" align="center" width="40%">
	<?=$Mprice?>
	</td>
	<td class="bodycell5" align="center" width="30%">
	<?
	if($user['uMoatLevel']!=5){
		?>
		<input name="moat" type="submit" value="Upgrade to Level <?=$Mnextlevel?>">
		<?
	}
	else{
		echo "-";
	}
	?>
	</td>
  </tr>
</table>
<?
if(!$Misupgrades){
	?>
	</form>
	<?
}
}
elseif($_POST['moat']){
?>
<table width="100%"  border="0">
  <tr>
	<td class="bodycell3">Bank</td>
  </tr>
  <tr>
	<td class="bodycell4" align="center">
	<?
	if($Mnextlevel=="-"){
		echo "There are no further upgrades for this.";
	}
	elseif($Mprice>$user['uGold']){
		echo "You don't have enough gold to upgrade.";
	}
	else{
		echo "You successfully upgraded your Moat Level.";
		$db->query("UPDATE users SET uGold=uGold-$Mprice,uMoatLevel=$Mnextlevel,uDefense=uDefense+(100000*uMoatLevel) WHERE uID='" . $user['uID'] . "'");
	}
	?>
	<br><br>

	</td>
  </tr>
</table>
<?
}

?>

 

 

Any help would be appreciated.

Link to comment
https://forums.phpfreaks.com/topic/37319-fatal-error-help/
Share on other sites

I Edited the CODE Below to show where line 97 is. Thanks for your help.

 

<?



$isadmin="*";



if($user['uMoatLevel']==1){
$Mprice = 2500000;
}
elseif($user['uMoatLevel']==2){
$Mprice = 7500000;
}
elseif($user['uMoatLevel']==3){
$Mprice = 22500000;
}
elseif($user['uMoatLevel']==4){
$Mprice = 67500000;
}
elseif($user['uMoatLevel']==5){
$Mprice = "-";
$Misupgrades = 1;
}
if($user['uMoatLevel']!=5){
$Mnextlevel = $user['uMoatLevel']+1;
}
if(!$_POST['moat']){
if(!$Misupgrades){
	?>
	<form action="upgradeMoat.php" method="post">
	<?
}
?>
<table width="100%"  border="0">
  <tr>
	<td colspan="3" class="bodycell3">Defense Upgrades</td>
  </tr>
  <tr>
	<td class="bodycell5" align="center" width="30%">
	<b>Moat Level</b>
	</td>
	<td class="bodycell5" align="center" width="40%">
	<?=$Mprice?>
	</td>
	<td class="bodycell5" align="center" width="30%">
	<?
	if($user['uMoatLevel']!=5){
		?>
		<input name="moat" type="submit" value="Upgrade to Level <?=$Mnextlevel?>">
		<?
	}
	else{
		echo "-";
	}
	?>
	</td>
  </tr>
</table>
<?
if(!$Misupgrades){
	?>
	</form>
	<?
}
}
elseif($_POST['moat']){
?>
<table width="100%"  border="0">
  <tr>
	<td class="bodycell3">Bank</td>
  </tr>
  <tr>
	<td class="bodycell4" align="center">
	<?
	if($Mnextlevel=="-"){
		echo "There are no further upgrades for this.";
	}
	elseif($Mprice>$user['uGold']){
		echo "You don't have enough gold to upgrade.";
	}
	else{
		echo "You successfully upgraded your Moat Level.";
----------------------LINE 97--------------------------------------------
		$db->query("UPDATE users SET uGold=uGold-$Mprice,uMoatLevel=$Mnextlevel,uDefense=uDefense+(100000*uMoatLevel) WHERE uID='" . $user['uID'] . "'");
-------------------------------------------------------------------------------------------
	}
	?>
	<br><br>

	</td>
  </tr>
</table>
<?
}

?>

Link to comment
https://forums.phpfreaks.com/topic/37319-fatal-error-help/#findComment-178507
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.