Shiny_Charizard Posted July 13, 2008 Share Posted July 13, 2008 Can anyone help me I keep getting this error: Fatal error: Call to a member function User() on a non-object in /home/tpfrpg/public_html/include/footer.php on line 67 I tried fixing it but I couldn't. Here is the code for the footer file: footer.php <?php #footer.php #Set LoggedIn Variable if(Session_Is_Registered("UserName") && Session_Is_Registered("PassWord")) { $LoggedIn = True; } else { $LoggedIn = False; } #Require Connect File Require_Once('connect.php'); $DB = new mysql(); $DB->Connect('localhost', 'tpfrpg', 'casey', 'tpfrpg_main'); /********************************************** SQL TEST FILE FOR HOW TO USE THE CONNECTION Regular commands such as mysql_*(.....) won't work. $sql = "SELECT id, echo FROM `tests` WHERE `id` = '1'"; $query = $DB->Query($sql); $newsrow = $DB->FetchRow($query); $id = $newsrow[0]; $echo = $newsrow[1]; echo "<b>Row</b><br /><br />ID: $id<br /> Echo: $echo<br><br />"; $num = $DB->FetchNum($query); echo "Number of rows: $num"; **********************************************/ #Display Content ?> <div align='center' id='Loading' class='LoadingOff'> <div id='LoadingDiv' class='LoadingDiv'><img src='http://tpfrpg.exoph.com/images/Loading.gif'></div> </div> </td> <td class='Nav' width='160' border='0' /><center> <?php #If The User Is Not Logged In if($LoggedIn == False) { #Display Nav ?> <div class='HNavDiv'>Main</div> <div class='NavDiv'><a href='index.php'>Home</a></div> <div class='NavDiv'><a href='register.php'>Register</a></div> <div class='NavDiv'><a href='login.php'>Login</a></div> <div class='FNavDiv'> </div> <?php } #If The User Is Logged In else { #Fetch The User's Details $Member = $function->User("$_SESSION[userName]"); #Count Pokemon Query $CPQuery = $DB->Query("SELECT * FROM `Pokemon` WHERE `Owner_ID` = '$_SESSION[user_ID]'"); $Total_Pokemon = $DB->FetchNum($CPQuery); #Slots 1-6 Details $Slot1 = $function->Slot(1,"$_SESSION[user_ID]"); $Slot2 = $function->Slot(2,"$_SESSION[user_ID]"); $Slot3 = $function->Slot(3,"$_SESSION[user_ID]"); $Slot4 = $function->Slot(4,"$_SESSION[user_ID]"); $Slot5 = $function->Slot(5,"$_SESSION[user_ID]"); $Slot6 = $function->Slot(6,"$_SESSION[user_ID]"); #Display Nav ?> <div class='HNavDiv'>Trainer Stats</div> <div class='NavDiv'><small> <b>UserName:</b> <a href='profile.php?Mode=View&ID= <?php echo "$_SESSION[user_ID]"; ?> '> <?php echo "$_SESSION[userName]"; ?></a><br /> <b>ID Number:</b> <?php echo "$_SESSION[user_ID]"; ?><br /> <b>IP Address:</b> <?php echo "$Member[Current_IP]"; ?><br /> <b>Position:</b> <?php echo "$Member[Position]"; ?><br /> <b>Poke Cash:</b> $<?php echo "$Member[Poke_Money]"; ?><br /> <b>Total Pokemon:</b> <?php echo "$Total_Pokemon"; ?><br /> <b>Total Gym Badges:</b> <?php echo "$Member[GymBadges]"; ?><br /> <b>Level:</b> <?php echo "$Member[Level]"; ?><br /> <b>Exp:</b> <?php echo "$Member[Exp_1]/$Member[Exp_2]"; ?><br /> </small> </div> <div class='FNavDiv'> </div> <br /> <div class='HNavDiv'>Pokémon Team</div> <div class='NavDiv'> <?php #If Slot 1 Is Empty if(empty($Slot1)) { echo "<img src='images/items/pokeball.png'><br />None Level 0"; } else { echo "<a href='javascript:;' onclick='javascript:window.open(\"pkmnstats.php?ID=$Slot1[Pkmn_ID]\",\"Pokemon_Stats\",\"toolbar=no,height=420px,width=200px\");'><img src='$Slot1[Pkmn_Icon]' border='0' alt='$Slot1[Nickname]($Slot1[Pkmn_Species])' title='Exp:$Slot1[Pkmn_Exp1] / $lot1[Pkmn_Exp2]'></a><br />$Slot1[Nickname] Level $Slot1[Pkmn_Level]"; } ?> </div> <div class='NavDiv'> <?php #If Slot 2 Is Empty if(empty($Slot2)) { echo "<img src='images/items/pokeball.png'><br />None Level 0"; } else { echo "<a href='javascript:;' onclick='javascript:window.open(\"pkmnstats.php?ID=$Slot2[Pkmn_ID]\",\"Pokemon_Stats\",\"toolbar=no,height=420px,width=200px\");'><img src='$Slot2[Pkmn_Icon]' border='0' alt='$Slot2[Nickname]($Slot2[Pkmn_Species])' title='Exp:$Slot2[Pkmn_Exp] / $Slot2[Pkmn_Exp2]'></a><br />$Slot2[Nickname] Level $Slot2[Pkmn_Level]"; } ?> </div> <div class='NavDiv'> <?php #If Slot 3 Is Empty if(empty($Slot3)) { echo "<img src='images/items/pokeball.png'><br />None Level 0"; } else { echo "<a href='javascript:;' onclick='javascript:window.open(\"pkmnstats.php?ID=$Slot3[Pkmn_ID]\",\"Pokemon_Stats\",\"toolbar=no,height=420px,width=200px\");'><img src='$Slot3[Pkmn_Icon]' border='0' alt='$Slot3[Nickname]($Slot3[Pkmn_Species])' title='Exp:$Slot3[Pkmn_Exp] / $Slot3[Pkmn_Exp2]'></a><br />$Slot3[Nickname] Level $Slot3[Pkmn_Level]"; } ?> </div> <div class='NavDiv'> <?php #If Slot 4 Is Empty if(empty($Slot4)) { echo "<img src='images/items/pokeball.png'><br />None Level 0"; } else { echo "<a href='javascript:;' onclick='javascript:window.open(\"pkmnstats.php?ID=$Slot4[Pkmn_ID]\",\"Pokemon_Stats\",\"toolbar=no,height=420px,width=200px\");'><img src='$Slot4[Pkmn_Icon]' border='0' alt='$Slot4[Nickname]($Slot4[Pkmn_Species])' title='Exp:$Slot4[Pkmn_Exp] / $Slot4[Pkmn_Exp2]'></a><br />$Slot4[Nickname] Level $Slot4[Pkmn_Level]"; } ?> </div> <div class='NavDiv'> <?php #If Slot 5 Is Empty if(empty($Slot5)) { echo "<img src='images/items/pokeball.png'><br />None Level 0"; } else { echo "<a href='javascript:;' onclick='javascript:window.open(\"pkmnstats.php?ID=$Slot5[Pkmn_ID]\",\"Pokemon_Stats\",\"toolbar=no,height=420px,width=200px\");'><img src='$Slot5[Pkmn_Icon]' border='0' alt='$Slot5[Nickname]($Slot5[Pkmn_Species])' title='Exp:$Slot5[Pkmn_Exp] / $Slot5[Pkmn_Exp2]'></a><br />$Slot5[Nickname] Level $Slot5[Pkmn_Level]"; } ?> </div> <div class='NavDiv'> <?php #If Slot 6 Is Empty if(empty($Slot6)) { echo "<img src='images/items/pokeball.png'><br />None Level 0"; } else { echo "<a href='javascript:;' onclick='javascript:window.open(\"pkmnstats.php?ID=$Slot6[Pkmn_ID]\",\"Pokemon_Stats\",\"toolbar=no,height=420px,width=200px\");'><img src='$Slot6[Pkmn_Icon]' border='0' alt='$Slot6[Nickname]($Slot6[Pkmn_Species])' title='Exp:$Slot6[Pkmn_Exp] / $Slot6[Pkmn_Exp2]'></a><br />$Slot6[Nickname] Level $Slot6[Pkmn_Level]"; }?> </div> <div class='FNavDiv'> </div> <?php } ?> </center> </td> </tr> </table> <table rules='rows' width='980' border='0' /> <tr border='0'><td class='Footer' border='0' /><center> <?php #Fetch Copyright From The Database $CopyRight1 = $DB->Query("SELECT * FROM `copyright`"); $CopyRight = $DB->FetchArray($CopyRight1); #Display Copyright echo "$CopyRight[Content]"; ?> </center> </td></tr></table> </center> <br /> <div valign='left' /> <form action='styleswitcher.php' method='POST' /> <select name='Style' /> <optgroup label='Style Switcher'> <option value='TPF' onclick='submit();' />TPF Default</option> </optgroup> </select> </form> <!-- Start Quantcast tag --> <script type="text/javascript" src="http://edge.quantserve.com/quant.js"></script> <script type="text/javascript">_qacct="p-75A9Iyr9XYgWs";quantserve();</script> <noscript> <a href="http://www.quantcast.com/p-75A9Iyr9XYgWs" target="_blank"><img src="http://pixel.quantserve.com/pixel/p-75A9Iyr9XYgWs.gif" style="display: none;" border="0" height="1" width="1" alt="Quantcast"/></a> </noscript> <!-- End Quantcast tag --> </body> </html> functions.php <?php #functions.php Require_Once('connect.php'); $DB = new mysql(); $DB->Connect('localhost', 'tpfrpg', 'casey', 'tpfrpg_main'); /********************************************** SQL TEST FILE FOR HOW TO USE THE CONNECTION Regular commands such as mysql_*(.....) won't work. $sql = "SELECT id, echo FROM `tests` WHERE `id` = '1'"; $query = $DB->Query($sql); $newsrow = $DB->FetchRow($query); $id = $newsrow[0]; $echo = $newsrow[1]; echo "<b>Row</b><br /><br />ID: $id<br /> Echo: $echo<br><br />"; $num = $DB->FetchNum($query); echo "Number of rows: $num"; **********************************************/ #Create Class For Functions class functions { #BBCode Function function BBCode($String) { #Strip HTML Tags From Comment $String = strip_tags($String); #Bold Text BBcode $String = str_replace("[b]","<b>",$String); $String = str_replace("[/b]","</b>",$String); $String = str_replace("[b]","<B>",$String); $String = str_replace("[/b]","</B>",$String); #Italic Text BBcode $String = str_replace("[i]","<i>",$String); $String = str_replace("[/i]","</i>",$String); $String = str_replace("[i]","<I>",$String); $String = str_replace("[/i]","</I>",$String); #Underlined Text BBcode $String = str_replace("[u]","<u>",$String); $String = str_replace("[/u]","</u>",$String); $String = str_replace("[u]","<U>",$String); $String = str_replace("[/u]","</U>",$String); #IMG BBcode $String = str_replace("[img]http://","<img src='",$String); $String = str_replace("[/img]","' border='0'>",$String); $String = str_replace("[img]http://","<IMG SRC='",$String); $String = str_replace("[/img]","' BORDER='0'>",$String); #Striked Text BBcode $String = str_replace("[s]","<s>",$String); $String = str_replace("[/s]","</s>",$String); $String = str_replace("[s]","<S>",$String); $String = str_replace("[/s]","</S>",$String); #URL BBcode $url_replace = array('/(\[url=)(.+)(\])(.+)(\[\/URL\])/','/(\[url=)(.+)(\])(.+)(\[\/url\])/'); $url_replacements = array('<A HREF="\\2">\\4</A>','<a href="\\2">\\4</a>'); $String = preg_replace($url_replace, $url_replacements, $String); #Replace the Word TPPC $String = str_replace("TPPC","The Porky Pig Center",$String); $String = str_replace("tppc","The Porky Pig Center",$String); $String = str_replace("TPPCRPG","The Porky Pig Center RPG",$String); $String = str_replace("tppcrpg","The Porky Pig Center RPG",$String); #Automatic Line Breaks $String = nl2br($String); } #Function Fetch User's Details From The DataBase function User($User) { $UQuery = $DB->Query("SELECT * FROM `Users` WHERE `UserName` = '$User'"); $FetchUQuery = $DB->FetchArray($UQuery); return $FetchUQuery; } #Function To Fetch Slot's Details From The DataBase function Slot($Slot,$OwnerID) { $SQuery = $DB->Query("SELECT * FROM `Pokemon` WHERE `Slot` = '$Slot' AND `Owner_ID` = '$OwnerID'"); $FetchSQuery = $DB->FetchArray($SQuery); return $FetchSQuery; } } ?> Can anyone please help me, please? Link to comment https://forums.phpfreaks.com/topic/114558-fatal-error-call-to-a-member-function-user-on-a-non-object/ Share on other sites More sharing options...
JonnyThunder Posted July 13, 2008 Share Posted July 13, 2008 The function "User" is a function belonging to the class "Functions". I don't see anywhere on the calling script, that the class is being instantiated, which means the functions within that class are unavailable. Link to comment https://forums.phpfreaks.com/topic/114558-fatal-error-call-to-a-member-function-user-on-a-non-object/#findComment-589069 Share on other sites More sharing options...
Shiny_Charizard Posted July 13, 2008 Author Share Posted July 13, 2008 I forgot to mention that instantiate the functions class on the header file. Link to comment https://forums.phpfreaks.com/topic/114558-fatal-error-call-to-a-member-function-user-on-a-non-object/#findComment-589086 Share on other sites More sharing options...
Shiny_Charizard Posted July 14, 2008 Author Share Posted July 14, 2008 -Bump- Link to comment https://forums.phpfreaks.com/topic/114558-fatal-error-call-to-a-member-function-user-on-a-non-object/#findComment-589790 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.