现在我想创建更新功能,我出现了未定义变量的问题。我使用相同的方法添加这个工作正常。我是编码的新手,也许有简单的答案,但我找不到。
$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);
public function update_event_base($event_basic,$event_id){
return
$this->db->where('event_id', $event_id)
->update('events', $event_basic);
}
严重性:注意
消息:未定义的变量:图片
答案 0 :(得分:0)
请检查一下。它可以帮到你。
$picture = $_FILES['picture']['name'];
$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')
];