Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 提交表单时Codeigniter未定义的偏移量:0_Php_Codeigniter - Fatal编程技术网

Php 提交表单时Codeigniter未定义的偏移量:0

Php 提交表单时Codeigniter未定义的偏移量:0,php,codeigniter,Php,Codeigniter,未定义的偏移量:提交后,我的编辑数据表单中发生0错误。 有时这是可行的,但大多数情况下是行不通的。知道错误发生在哪里吗 function data_user_edit($id = ''){ $user = $this->adminmodel->selectdata('user where id_user = "'.$id.'"')->result_array(); $data = array( 'title'

未定义的偏移量:提交后,我的编辑数据表单中发生0错误。 有时这是可行的,但大多数情况下是行不通的。知道错误发生在哪里吗

 function data_user_edit($id = ''){

$user = $this->adminmodel->selectdata('user where id_user = "'.$id.'"')->result_array();

            $data = array(
                'title'             => '.:: EVALUASI PROSES BELAJAR MENGAJAR GURU SMA NEGERI 4 BEKASI::. ',
                'titlesistem'       => $this->model->getTitle(),
                'nama'              => $user[0]["nama"],
                'id_user'           => $user[0]["id_user"],
                'status'            => 'edit',
                'username'          => $user[0]["username"],
                'password'          => $user[0]["password"],
                'level'             => $user[0]["level"],
                'tipeakun'          => $user[0]["tipeakun"],
        );

            $this->load->view('admin/header',$data);
            $this->load->view('admin/data_user_form');
            $this->load->view('admin/footer');

检查
$user
是否为空并检查您所编码的内容是否有效检查
$user
是否为空并检查您所编码的内容是否有效想象一个场景,特别是在公共控制器中,用户手动进入您的
页面/数据\u用户\u编辑
,并且没有输入他们的id。这是他们将得到的错误,因为
$user
返回bool或没有行,因此没有定义
$user[0]

首先,如果它是一个用户编辑页面,那么我很惊讶你允许他们手动在url中输入id,并通过更改url来更改其他用户的详细信息。这应该从
会话
变量中获取,他们应该登录才能看到甚至到达页面

其次,在尝试访问
结果之前,您当然应该检查
num_rows()>0

第三,您可以对一条记录使用
行数组()
,而不是
结果数组()
。您不需要
$user[0]
,只需使用
$user

e、 g


想象一个场景,特别是在公共控制器中,用户手动进入您的
somepage/data\u user\u edit
,并且没有键入他们的id。这是他们将得到的错误,因为
$user
返回bool或没有行,因此未定义
$user[0]

首先,如果它是一个用户编辑页面,那么我很惊讶你允许他们手动在url中输入id,并通过更改url来更改其他用户的详细信息。这应该从
会话
变量中获取,他们应该登录才能看到甚至到达页面

其次,在尝试访问
结果之前,您当然应该检查
num_rows()>0

第三,您可以对一条记录使用
行数组()
,而不是
结果数组()
。您不需要
$user[0]
,只需使用
$user

e、 g


这仅适用于管理员,管理员可以编辑其他用户的数据。那么,你知道如何让它继续工作吗?然后删除上面的所有内容
$query=$this->adminmodel->selectdata('user where id_user=“'.$id.”)
并像以前一样使用它。这仅适用于管理员,管理员可以编辑其他用户的数据。那么,你知道如何让它继续工作吗?然后删除上面的所有内容
$query=$this->adminmodel->selectdata('user where id_user=“'.$id.”)并像以前一样使用它。
if (is_null($this->session->id)) {
    show_error('not allowed');
}

$id = $this->session->id;

$query = $this->adminmodel->selectdata('user where id_user = "'.$id.'"');

if ($query->num_rows() !== 1) {
    show_error('no user with id');
}

$user = $query->row_array();

            $data = array(
                'title'             => '.:: EVALUASI PROSES BELAJAR MENGAJAR GURU SMA NEGERI 4 BEKASI::. ',
                'titlesistem'       => $this->model->getTitle(),
                'nama'              => $user["nama"],
                'id_user'           => $user["id_user"],
                'status'            => 'edit',
                'username'          => $user["username"],
                'password'          => $user["password"],
                'level'             => $user["level"],
                'tipeakun'          => $user["tipeakun"],
        );

            $this->load->view('admin/header',$data);
            $this->load->view('admin/data_user_form');
            $this->load->view('admin/footer');