gpt4 book ai didi

php - CodeIgniter:发生数据库错误错误号:1054

转载 作者:行者123 更新时间:2023-11-29 19:31:06 25 4
gpt4 key购买 nike

我在使用 CodeIgniter 时遇到此错误:

A Database Error Occurred

Error Number: 1054

Unknown column 'data' in 'field list'

SELECT `data` FROM `ci_sessions` WHERE `id` = '4j5h21j1us9nhah0qc1hqmmmevb1oa2f' AND `ip_address` = '::1'

Filename: C:/wamp64/www/life/app/delta/system/database/DB_driver.php

Line Number: 691

真是令人沮丧。我已经尝试了我所知道的一切。

这是我的 Controller 的一部分,我认为错误来自

public function index() {
if ($this->session->userdata('logged_in') == TRUE) {
if ($this->session->userdata('usr_access_level') == 1) {
redirect('users');
} else {
redirect('me');
}
}


$data['login_fail'] = TRUE;
$this->load->view('common/login_header');
$this->load->view('admin/signin', $data);
$this->load->view('common/footer');
} else {
$data = array(
'usr_id' => $row->usr_id,
'acc_id' => $row->acc_id,
'user_name' => $row->user_name,
'usr_access_level' => $row->usr_access_level,
'logged_in' => TRUE
);

// Save data to session
$this->session->set_userdata($data);
if ($data['usr_access_level'] == 2) {
redirect('me');
} elseif ($data['usr_access_level'] == 1) {
redirect('users');
} else {
redirect('me');
}

}

这是 Controller 的模型

class _model extends CI_Model 

{

function __construct()
{
parent::__construct();
}

public function does_user_exist($email) {
$this->db->where('user_name', $email);
$query = $this->db->get('users');
return $query;
}

}

最佳答案

将您的代码修改为以下内容

if ($this->session->userdata('usr_access_level') == 2) {
redirect('me');
} elseif ($this->session->userdata('usr_access_level') == 1) {
redirect('users');
} else {
redirect('me');
}

关于php - CodeIgniter:发生数据库错误错误号:1054,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41777700/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com