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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.