Jump to content

Call to a member function on a non-object in...


Locked

Recommended Posts


<?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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.