2013-05-08 1 views
0

У меня есть ошибка 1054 в Codeigniter, и я не знаю почему. Я хочу создать форму входа и проверить, зарегистрирован ли пользователь или нет.Ошибка 1054 в Codeigniter 2.1.3

Но я только создать простой вид и контроллер и следующее сообщение об ошибке отображается:

Error Number: 1054 

Unknown column 'user_data' in 'field list' 

INSERT INTO `ci_sessions` (`session_id`, `ip_address`, `user_agent`, `last_activity`, `user_data`) VALUES ('c392322ac31b7fac1c2d79cfbde9edf7', '127.0.0.1', 'Opera/9.80 (Windows NT 6.1) Presto/2.12.388 Version/12.15', 1368010716, '') 

Filename: C:\wamp\www\..\system\database\DB_driver.php 

Line Number: 330 

Я только создал таблицу сеанса с этим сценарием:

CREATE TABLE IF NOT EXISTS `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL, 
ip_address varchar(45) DEFAULT '0' NOT NULL, 
user_agent varchar(50) NOT NULL, 
last_activity int(10) unsigned DEFAULT 0 NOT NULL, 
PRIMARY KEY (session_id) 
); 

Вид:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="utf-8"> 
<title>Anuncios</title> 
<link rel="stylesheet" href="/Pruebas/css/estilos.css" type="text/css" 
    media="screen"/>  
</head> 

<body> 

<div id="contenedor"> 
<div id="menu"> 
    <label for="home" id="inicio"><a href="http://localhost/Pruebas/index.php/ 
cindice/">Inicio</a></label> 
    <label for="acceso" id="login"><a href="http://localhost/Pruebas/index.php/ 
cindice/publicar">Publicar anuncio</a></label> 
    <label for="reg" id="registro"><a href="http://localhost/Pruebas/index.php/ 
cindice/registro">Registro</a></label> 
    <label for="empresa" id="sobrempresa"><a href="http://localhost/Pruebas/ 
index.php/cindice/sobempresa">Sobre nosotros</a></label> 
    <label for="contacto" id="contactar"><a href="http://localhost/Pruebas/ 
index.php/cindice/contacto">Cont&aacute;ctanos</a></label> 
</div> 
</div> 

</body> 
</html> 

Контроллер:

<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 


class Cindice extends CI_Controller { 

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

public function index() 
{ 
    $this->load->view('indice'); 
} 

public function publicar() 
{ 
    echo "Aqu&iacute; se publica el anuncio"; 
} 

public function acceso() 
{ 
    echo "Esto es el acceso"; 
} 


} 
?> 

Как исправить эту проблему?

Спасибо.

ответ

2

manual утверждает, ваша таблица ci_sessions должны быть созданы таким образом:

CREATE TABLE IF NOT EXISTS `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL, 
ip_address varchar(45) DEFAULT '0' NOT NULL, 
user_agent varchar(120) NOT NULL, 
last_activity int(10) unsigned DEFAULT 0 NOT NULL, 
user_data text NOT NULL, 
PRIMARY KEY (session_id), 
KEY `last_activity_idx` (`last_activity`) 
); 

Обратите внимание на поле «user_data», который отсутствует в таблице.

+0

Это работает, спасибо. – axmug