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 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误