doutan4831 2017-03-11 07:55
浏览 45
已采纳

Codeigniter未定义变量[重复]

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>
  • 写回答

1条回答 默认 最新

  • douyan8027 2017-03-11 08:37
    关注

    Please check this.It may help you.

    $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')
                               ];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 vivo手机锁屏密码忘记了需要手机里的资料在百度里搜可以用ADB命令希望帮帮我
  • ¥15 关于#网络#的问题:网络是从楼上引一根网线下来,接了2台傻瓜交换机,也更换了ip还是不行
  • ¥15 资源泄露软件闪退怎么解决?
  • ¥15 CCF-CSP 2023 第三题 解压缩(50%)
  • ¥30 comfyui openpose报错
  • ¥20 Wpf Datarid单元格闪烁效果的实现
  • ¥15 图像分割、图像边缘提取
  • ¥15 sqlserver执行存储过程报错
  • ¥100 nuxt、uniapp、ruoyi-vue 相关发布问题
  • ¥15 浮窗和全屏应用同时存在,全屏应用输入法无法弹出