Locked Posted December 6, 2007 Share Posted December 6, 2007 <?php //************************CLASSES*****************************// class db{ function Fetch($string){ $this->$query=mysql_query("$string") or die(mysql_error()); $this->$result=mysql_fetch_array($this->$query) or die(mysql_error()); return $this->$result; } } //**************************CLASSES-END*************************// //**************************GLOBALS*************************// $db=new db; $ip=getenv('REMOTE_ADDR'); $userid=$_SESSION['userid']; $upassword=$_SESSION['password']; $uuser=$_SESSION['username']; global $db,$ip,$userid,$upassword,$uuser; //**************************GLOBALS-END*************************// //**************************FUNCTIONS*************************// function Theme($title,$content,$pagetitle=""){ if($pagetitle) $pagetitle="- $pagetitle"; $theme=implode("", file("include/theme.html")); $q=$db->Fetch("SELECT name,level,money,points from users where userid=$userid"); $uname=$q[name]; $ulevel=$q[level]; $upoints=$q[points]; $umoney=$q[money]; $array=array( "title" => "$title", "page" => "$pagetitle", "uname" => "$uname", "ulevel" => "$ulevel", "upoints" => "$upoints", "umoney" => "$umoney", "content" => "$content"); foreach($array as $key => $value){ $theme=str_replace("{".$key."}",$value,$theme); } echo $theme; } //**************************FUNCTIONS-END*************************// ?> $q=$db->Fetch("SELECT name,level,money,points from users where userid=$userid"); The above is were it errors. I cant seem to find out why it is erroring. The only thing i can think of is because it is in a function. Just unable to think of a fix for it. Link to comment https://forums.phpfreaks.com/topic/80465-call-to-a-member-function-on-a-non-object-in/ Share on other sites More sharing options...
trq Posted December 6, 2007 Share Posted December 6, 2007 You need to either move this line... global $db,$ip,$userid,$upassword,$uuser; into yuor Theme function, or better still, pass these variables into it as arguments. Link to comment https://forums.phpfreaks.com/topic/80465-call-to-a-member-function-on-a-non-object-in/#findComment-407956 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.