Welcome Guest, Not a member yet? Register   Sign In
Some questions from novice..
#2

[eluser]TheFuzzy0ne[/eluser]
First of all, I'm not sure why you're calling parent::Controller() from your links method, I think it's unnecessary.

As for your first error, it sounds like you might not be running PHP 5. Try this instead:

Code:
class User extends Controller {
        
    function User(){
        parent::Controller();
        $session_id=$this->session->userdata('session_id'); //The error called this line
        if(!empty($session_id)){
            $user_id=$this->session->userdata('user_id');
            if (!is_numeric($user_id) OR $user_id < 1)
                header('Location:'.site_url('/'));            
        }
        else
            header('Location:'.site_url('/'));    
    }    
      
    function links($link_id=0){    
        
        if(is_numeric($link_id) && $link_id >= 1){    

            $q = Doctrine_Query::create()->from('Links')->where('id  = '.$link_id);
            $ret=$q->execute();
            $data['data']['link_id'] = $ret[0]['id'];
            $data['data']['link'] = $ret[0]['link'];
            
            $q = Doctrine_Query::create()->from('ActiveLink')->where('link_id  = '.$data['data']['link_id'].' AND user_id='.$this->session->userdata('user_id'));
            $data['data']['user_links']=$q->execute();  //Error. If $data['data']['user_links'] is empty, then all is ok, else there is an error.
            
            $data['tpl']='user/user_links_info';
            $this->load->view('header');
            $this->load->view('user/user', $data);
            $this->load->view('footer');            
        }        
        else{
            $q = Doctrine_Query::create()->from('Links')->orderBy('id DESC');
            $data['data']['links'] = $q->execute();
  
            $data['tpl']='user/user_links';
            $this->load->view('header');
            $this->load->view('user/user', $data);
            $this->load->view('footer');
        }

As for your second error, you can't use isset() on a function, plus you shouldn't need to, as the session class returns FALSE if the specified key is not set.

EDIT: Come to think about it, if you weren't running PHP 5, then __construct wouldn't be called. Try loading the session class from within the constructor. I suspect you might not be using the correct syntax in your autoload.php.


Messages In This Thread
Some questions from novice.. - by El Forum - 04-13-2009, 01:39 PM
Some questions from novice.. - by El Forum - 04-13-2009, 01:48 PM
Some questions from novice.. - by El Forum - 04-13-2009, 02:49 PM
Some questions from novice.. - by El Forum - 04-13-2009, 06:17 PM
Some questions from novice.. - by El Forum - 04-13-2009, 10:46 PM
Some questions from novice.. - by El Forum - 04-14-2009, 03:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB