Fatal error: Call to a member function on a non-object in
Posted: Mon Feb 05, 2007 8:32 pm
Ok, I have a Browser Based RPG. In the RPG you can upgrade your Mine level upgrade.php which will than add +1 to uMineLevel in the database. I have edited the upgrade.php file into upgradeMoat.php and added a field to the user database called uMoatLevel, so When you go to upgradeMoat.php and purchase it it will update the Database +1 to the uMoatLevel and then add some to the uDefense field because a Moat as we all know is meant to be defense for a castle
So...everything is working fine with the upgradeMoat.php on its own. It takes away the proper amount of gold, adds +1 to the database were supposed to be , and adds defense. But I want to include the upgradeMoat.php into the upgrade.php so its all on one upgrade page. Below you will find the code.
upgrade.php
upgradeMoat.php
I would appreciate any help on this as When i tried just including the upgradeMoat.php file into the upgrade.php file it worked sort of..
upgrade.php
Code: Select all
<?
$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){
?>
<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");
?>Code: Select all
<?
$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['uMineLevel']+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>Mine 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="mine" 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 Mine Level.";
$db->query("UPDATE users SET uGold=uGold-$Mprice,uMoatLevel=$Mnextlevel,uDefense=uDefense+(100000*uMoatLevel) WHERE uID='" . $user['uID'] . "'");
}
?>
<br><br>
</td>
</tr>
</table>
<?
}
?>