netpants Posted February 6, 2007 Share Posted February 6, 2007 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 More sharing options...
trq Posted February 6, 2007 Share Posted February 6, 2007 Which is line 97? Link to comment https://forums.phpfreaks.com/topic/37319-fatal-error-help/#findComment-178401 Share on other sites More sharing options...
netpants Posted February 6, 2007 Author Share Posted February 6, 2007 I am not sure how to find that out. Link to comment https://forums.phpfreaks.com/topic/37319-fatal-error-help/#findComment-178421 Share on other sites More sharing options...
netpants Posted February 6, 2007 Author Share Posted February 6, 2007 well what does that error message mean? Link to comment https://forums.phpfreaks.com/topic/37319-fatal-error-help/#findComment-178438 Share on other sites More sharing options...
almightyegg Posted February 6, 2007 Share Posted February 6, 2007 could be a selection of things. We need to know the line it says is wrong Link to comment https://forums.phpfreaks.com/topic/37319-fatal-error-help/#findComment-178442 Share on other sites More sharing options...
Balmung-San Posted February 6, 2007 Share Posted February 6, 2007 I am not sure how to find that out. Count. Or open it in an IDE with line numbers. well what does that error message mean? Without the line number, we don't know either. Link to comment https://forums.phpfreaks.com/topic/37319-fatal-error-help/#findComment-178444 Share on other sites More sharing options...
netpants Posted February 6, 2007 Author Share Posted February 6, 2007 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 More sharing options...
netpants Posted February 7, 2007 Author Share Posted February 7, 2007 Anyone have any ideas? Link to comment https://forums.phpfreaks.com/topic/37319-fatal-error-help/#findComment-178747 Share on other sites More sharing options...
13th_Star Posted February 7, 2007 Share Posted February 7, 2007 hmmm I'll take a guess. looks like its something to do with " . $user['uID'] . " in the sql query. try doing $user_uid = $user['uID']; then changing where it says " . $user['uID'] . " (including the ") to $user_uid might work sorry if not. Link to comment https://forums.phpfreaks.com/topic/37319-fatal-error-help/#findComment-178751 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.