Jump to content

getting a new error... well new for me :p


rhyno

Recommended Posts

Fatal error: Call to a member function on a non-object in /home/..../includes/header.php on line 6

is the result of my code... line 6 looks like this

$view=new View();
$view->SetFolderlevel(0);

and the setfolderlevel function with in the class looks like this...

function SetFolderlevel($newFolderlevel)

{$this->folderlevel = new $newFolderlevel;}

function GetFolderlevel()

{	$folderPath ="";

	for($i=0; $i<$this->folderlevel; $i++) $folderPath .="../";

	return $folderPath;

}

Any ideas on this one?

Link to comment
Share on other sites

Maybe you meant to do:

 

{$this->folderlevel = $newFolderlevel;}

 

Having the "new" in there and the 0 (zero) value you were passing it, was trying to force PHP to create a new class object called 0. i.e.  {$this->folderlevel = new 0();} which is not possible/correct.

 

FYI:

 

For your second method (function), you don't need to do a loop when you can use str_repeat(). Example:

 

function GetFolderlevel() {

 

    return str_repeat('../', $this->folderlevel);

}

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.