This question already has an answer here:
Undefined
Now I want to create update function and I had appeared problem with undefined variable. I am using same method in adding there this working fine. I am newbie in coding maybe there have simple answer but I cannot find.
Controller
$event_title = $this->input->post('title');
$event_description = $this->input->post('description');
$event_phone = $this->input->post('phone');
$event_email = $this->input->post('email');
$event_keywords = $this->input->post('keywords');
$date_start = $this->input->post('date_start');
$time_start = $this->input->post('time_start');
$date_end = $this->input->post('date_end');
$time_end = $this->input->post('time_end');
$start = date_format(date_create( $date_start.' '.$time_start),"Y-m-d H:i:s");
$end = date_format(date_create( $date_end.' '.$time_end),"Y-m-d H:i:s");
if(!empty($_FILES['picture']['name']))
{
$data['picture'] = $this->validator->upload_image('./uploads/events/main','picture');
$this->validator->resize_image($data['picture'],'./uploads/events/main','event_main_size');
}
$event_basic = [
'title' => $event_title,
'main_photo' => $picture,
'description' => $event_description,
'email' => $event_email,
'phone' => $event_phone,
'keywords' => $event_keywords,
'start' => $start,
'end' => $end,
'created_at' => date('c')
];
$this->events_model->update_event_base($event_basic,$event_id);
Model
public function update_event_base($event_basic,$event_id){
return
$this->db->where('event_id', $event_id)
->update('events', $event_basic);
}
Error
Severity: Notice
Message: Undefined variable: picture
</div>