Click to See Complete Forum and Search --> : Fatal error: Call to a member function topic_password_log_in() on a non-object


TeraCell
March 19th, 2008, 08:25 PM
I am trying to program a feature for Invision Power Board 2.3 where the member can enter a password for a topic and others can only see the topic if they know the password. I am basing it of some old code for from a previous version, however I get this error now:

Fatal error: Call to a member function topic_password_log_in() on a non-object

The bit of code I added is this:

if( $this->topic['topic_read_perms'] && $this->topic['topic_read_perms'] != '*' )
{
if( $this->ipsclass->member['id'] != $this->topic['starter_id'] )
{
if( ! $this->ipsclass->input['L'] )
{
$cookie_pass = $this->ipsclass->my_getcookie( 'ipbtopicpass_'.$this->topic['tid'] );
if( trim($cookie_pass) != md5($this->topic['topic_read_perms']) )
{
$this->output = $this->ipsclass->compiled_templates['skin_topic']->topic_password_log_in( $this->topic['tid'] );

$this->nav = $this->ipsclass->forums->forums_breadcrumb_nav( $this->forum['id'] );
$this->nav[] = "<a href='{$this->ipsclass->base_url}showtopic={$this->topic['tid']}'>{$this->topic['title']}</a>";

$this->ipsclass->print->add_output( $this->output );
$this->ipsclass->print->do_output( array( 'TITLE' => $this->ipsclass->vars['board_name']." -> ".$this->topic['title'],
'JS' => 0,
'NAV' => $this->nav,
) );
}
}
else
{
if( $this->ipsclass->input['topic_pwd'] == "" )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'pass_blank' ) );
}

if( $this->ipsclass->input['topic_pwd'] != $this->topic['topic_read_perms'] )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'wrong_pass' ) );
}

$this->ipsclass->my_setcookie( "ipbtopicpass_".$this->topic['tid'], md5($this->ipsclass->input['topic_pwd']) );

$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['logged_in'], "showtopic=".$this->topic['tid'] );
}

}
}


Any ideas? :) Help would be GREATLY appreciated.

PeejAvery
March 19th, 2008, 09:41 PM
Well, that means that one of the variables in that line has either not been declared yet, or is not of the object data type. I would suggest using is_object() (http://us2.php.net/manual/en/function.is-object.php) to test those variables.