Welcome Guest, Not a member yet? Register   Sign In
[SOLVED]when the session inserts into table, database will show error.. how to solve?
#1

[eluser]suba[/eluser]
Hi,

when I load my page , i will get this database error page

INSERT INTO `sgg_sessions` (`session_id`, `ip_address`, `user_agent`, `last_activity`) VALUES ('1e594d784c02d45d47ee24e12e2a6791', '0.0.0.0', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv', 1295177075)


My config file settings:

Code:
$config['sess_cookie_name']        = 'sgg_session';
$config['sess_expiration']        = 7200;
$config['sess_encrypt_cookie']    = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']        = 'sgg_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent']    = TRUE;
$config['sess_time_to_update']     = 300;

I want to save session into my database. But When i execute my home page, It shows the above error.
pls advice to me. Thanks.
#2

[eluser]JamieBarton[/eluser]
What is on the error page? That's just the query...

Does it not say why? Such as table doesn't exist, or row doesn't exist etc..?

Have you created the table and rows for the sessions, silly question I know...
#3

[eluser]suba[/eluser]
Thanks..

Yes, I have created the table.

table name is sgg_sessions.

But When I set
Code:
$config['sess_use_database']    = FALSE;

It does not show error. Because $config['sess_use_database'] variable is false

But I like to store session variable into table.

still database error message

do you know where session table sql query executes?
#4

[eluser]WanWizard[/eluser]
You still haven't told us what the error message is...
#5

[eluser]cideveloper[/eluser]
Since we are unable to see the actual error lets throw out some other possible reasons.

Do you have your database settings configured in application/config/database.php?
#6

[eluser]suba[/eluser]
really sorry.. sorry ... error is


A Database Error Occurred

Error Number: 1364

Field 'user_data' doesn't have a default value

INSERT INTO `sgg_sessions` (`session_id`, `ip_address`, `user_agent`, `last_activity`) VALUES ('453f5ae1891d6336b821ca09e756e570', '0.0.0.0', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv', 1295241345)
#7

[eluser]cideveloper[/eluser]
ok almost got it. Please show your controller code that gives you this error.
#8

[eluser]suba[/eluser]
This is my config settings:

Code:
$config['sess_cookie_name']        = 'sgg_session';
$config['sess_expiration']        = 7200;
$config['sess_encrypt_cookie']    = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']        = 'sgg_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent']    = TRUE;
$config['sess_time_to_update']     = 300;

This is my default controller.
Code:
<?php

class Girl_Guides extends Controller {

    function __construct()
    {
        parent::Controller();
    }
    
    function index()
    {
        $this->load->view('home/header');
        $this->load->view('home/footer');
    }
}

When I browse any controller, It will show the above database error.

my autoload settings:
Code:
$autoload['model'] = array('sgg_model');
$autoload['libraries'] = array('session','database');
$autoload['config'] = array('sgg_config');
#9

[eluser]cideveloper[/eluser]
There is nothing wrong with your code. I have found a reference to your problem on the EE forums. See here or check this out.

Are you hosting with a hosting service or is this a local dev box?
#10

[eluser]suba[/eluser]
This is locally now. Later I will upload to hosting server




Theme © iAndrew 2016 - Forum software by © MyBB