EllisLab text mark
Advanced Search
     
[Can’t use method return value in write context] for checking a form variable
Posted: 29 September 2010 12:35 PM
Joined: 2010-09-28
30 posts

This function is within a controller,

function settings()
        
{
            $data[
'members']=TRUE;

            
$this->load->model('user_model');
            
$user=$this->user_model;
            
/*-- Update Settings --*/
            
            
if( isset($this->input->post('update')) )
            
{
                $name
=$this->input->post('name');
                
$pp_email=$this->input->post('pp_email');
                
$country=$this->input->post('country');
                
                
$user->update_user($name$pp_email$country);
            
}
            
                        
            $data[
'action']='settings';
            
$data['user_data']=$user->get_user();
            
            
$this->load->view('members/home'$data);
        

I’m getting an error @ [if( isset($this->input->post(‘update’)) )]

Why?

Erro:

Can’t use method return value in write context

 
Posted: 30 September 2010 12:31 AM   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-18
678 posts

you don’t need to check if it’s set. Just use:

if( $this->input->post('update') ) 

CodeIgniter will return a false if there is no variable in post with that key
                                   
From the user_guide:

The function returns FALSE (boolean) if the item you are attempting to retrieve does not exist.

 Signature 

Quality Coder | Looking for work? | Logo by InsiteFX