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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.