简体   繁体   English

遇到PHP错误严重性:通知消息:未定义的属性:stdClass :: $ file文件名:controllers / arsip.php行号:137

[英]A PHP Error was encountered Severity: Notice Message: Undefined property: stdClass::$file Filename: controllers/arsip.php Line Number: 137

I'm new to codeigniter. 我是Codeigniter的新手。 i try using phpmyadmin database and i have troubled to edit an record. 我尝试使用phpmyadmin数据库,但我无法编辑记录。

A PHP Error was encountered
Severity: Notice
Message: Undefined property: stdClass::$file
Filename: controllers/arsip.php
Line Number: 137

this part of arsip.php in directory controller that line number show error 目录控制器中这部分arsip.php的行号显示错误

   function edit($id)
   {
    $judul = $this->input->post('no',TRUE);
    $config['file_name'] = $judul;
    $config['upload_path'] = './uploads/';
    $config['allowed_types'] = 'pdf|doc|docx';
    $config['max_size'] = '1000000';
    $data['title']="Edit data Arsip";
    $this->_set_rules();
    $this->load->library('upload', $config);
    $this->upload->initialize($config);
    $files = (object) $_FILES;
    $f_data = (object) $files->file; //is problem
    $file=$this->upload->file_name;
    $id = $this->input->post("no");

    if ($this->form_validation->run() == FALSE)
    {
        $result["msg"] = validation_errors();
        ;
        $result["success"] = false;
    }
    elseif($f_data->name != "")
    {   
        if (!$this->upload->do_upload("file")) {
            $result["content"]  = $this->upload->display_errors("", "");
            $result["success"]  = false;
        }
        else
        {
            $fdata = (object) $this->upload->data();

            $data = array(
            'no_arsip'=>$this->input->post('no'),
            'tahun'=>$this->input->post('tahun'),
            'nama_kapal'=>$this->input->post('nama_kapal'),
            'perihal'=>$this->input->post('perihal'),
            'file' => $fdata->file_name,
            );
            $this->m_arsip->update($id,$info);
            $data['arsip']=$this->m_arsip->cek($id)->row_array();
            $data['message']="<div class='alert alert-success'>Data berhasil diupdate</div>";
            redirect('arsip');
        }
    }
    else
    {
        $data = array(
            'no_arsip'=>$this->input->post('no'),
            'tahun'=>$this->input->post('tahun'),
            'nama_kapal'=>$this->input->post('nama_kapal'),
            'perihal'=>$this->input->post('perihal'),
        );
        $this->m_arsip->update($id,$info);
            $data['arsip']=$this->m_arsip->cek($id)->row_array();
            $data['message']="<div class='alert alert-success'>Data berhasil diupdate</div>";
            redirect('arsip');
    }   

    echo json_encode($result);
}

Whenever you get an error like: 每当出现以下错误时:

Message: Undefined property: stdClass::$file

it means PHP can tell is looking at a stdClass object, however, it can not find (in this case) the property "file". 这意味着PHP可以确定正在查看stdClass对象,但是,在这种情况下,它找不到属性“文件”。

To debug this: 要调试此:

after $files = (object) $_FILES; $files = (object) $_FILES; and before $f_data = (object) $files->file; 并且在$f_data = (object) $files->file; write: 写:

die(var_vump($files)); 

This will tell you what is actually populating the object. 这将告诉您实际填充对象的内容。

Also, my guess would be the input type="file" name is not set to "file" which is why PHP can't find it in the object. 另外,我的猜测是输入type =“ file”名称没有设置为“ file”,这就是为什么PHP在对象中找不到它的原因。

Hope this helps! 希望这可以帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 遇到 PHP 错误严重性:通知消息:未定义的属性:stdClass::$comment_count 文件名:blog/index.php 行号:35 - A PHP Error was encountered Severity: Notice Message: Undefined property: stdClass::$comment_count Filename: blog/index.php Line Number: 35 遇到PHP错误严重性:通知消息:未定义的属性:Social :: $ social_model文件名:controllers / social.php行号:10 - A PHP Error was encountered Severity: Notice Message: Undefined property: Social::$social_model Filename: controllers/social.php Line Number: 10 遇到PHP错误严重性:通知消息:未定义的属性:stdClass :: $ abbrev - A PHP Error was encountered Severity: Notice Message: Undefined property: stdClass::$abbrev 遇到PHP错误严重性:通知消息:未定义的属性:CI_Loader :: $ p文件名:Templates / public.php行号:24 - A PHP Error was encountered Severity: Notice Message: Undefined property: CI_Loader::$p Filename: Templates/public.php Line Number: 24 遇到PHP错误严重性:通知消息:未定义的属性:stdClass :: $$ moderator_id,使用codeigniter - A PHP Error was encountered Severity: Notice Message: Undefined property: stdClass::$moderator_id, using codeigniter 遇到 PHP 错误严重性:注意消息:试图获取非对象的属性文件名:blog/index.php 行号:23 - A PHP Error was encountered Severity: Notice Message: Trying to get property of non-object Filename: blog/index.php Line Number: 23 遇到 PHP 错误严重性:警告消息:未定义属性:stdClass::$cancelled - A PHP Error was encountered Severity: Warning Message: Undefined property: stdClass:: $cancelled 代码点火器:遇到PHP错误严重性:注意消息:未定义的变量:页面文件名:admin / display_page.php行号:18 - Code Igniter: A PHP Error was encountered Severity: Notice Message: Undefined variable: page Filename: admin/display_page.php Line Number: 18 遇到 PHP 错误严重性:警告消息:未定义属性:stdClass::$cancelled - A PHP Error was encountered Severity: Warning Message: Undefined property: stdClass::$cancelled 遇到 PHP 错误严重性:通知消息:未定义索引:问题 - A PHP Error was encountered Severity: Notice Message: Undefined index: questions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM