Database Error loading my ci_session - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Database Error loading my ci_session (/showthread.php?tid=32172) |
Database Error loading my ci_session - El Forum - 07-14-2010 [eluser]Unknown[/eluser] hi there I'm new at CI I was in the middle of a tutorial how to create a log in form when I stumbled into this error: A Database Error Occurred Error Number: 1364 Field 'user_data' doesn't have a default value INSERT INTO `ci_sessions` (`session_id`, `ip_address`, `user_agent`, `last_activity`) VALUES ('516751bf8b43c5e9be41ff1751350a64', '127.0.0.1', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv', 1279172903) can any one help me, you see I'm a newbie and only have a basic skills in php any help would be greatly appreciated, thanks Database Error loading my ci_session - El Forum - 07-15-2010 [eluser]BrianL[/eluser] WHen you get strange MySQL errors use MySQL forums... every possible error has hundreds of posts At first glance error is simple; you haven't defined user_data column to have default value of NULL and in your query there is no value for user_data. Solution is to either change column or change query to set user_data to ''. I suggest downloading MySQL Workbench. Database Error loading my ci_session - El Forum - 07-15-2010 [eluser]InsiteFX[/eluser] Code: -- InsiteFX Database Error loading my ci_session - El Forum - 07-16-2010 [eluser]Derek Allard[/eluser] InsiteFX has it right. You are saving sessions to a db without having created a table for it. Take another look at "Saving Session Data to a Database" in http://ellislab.com/codeigniter/user-guide/libraries/sessions.html Database Error loading my ci_session - El Forum - 07-16-2010 [eluser]WanWizard[/eluser] Nope. That would generate a table not found message. In this case, the user_data is defined like in InsiteFX's example (NOT NULL), but the INSERT from create_sess() doesn't include the user_data field, so it tries to insert a NULL value, which is not allowed. So, either remove the 'NOT NULL' from your field definition, or add a "DEFAULT ""' to make sure it always has a value. EDIT: Which means that the example in the user_guide is wrong. Database Error loading my ci_session - El Forum - 07-16-2010 [eluser]Derek Allard[/eluser] Oh snap! Right you are. Updating userguide example for strict mode db. Database Error loading my ci_session - El Forum - 11-08-2010 [eluser]theshiftexchange[/eluser] [quote author="Derek Allard" date="1279302677"]Oh snap! Right you are. Updating userguide example for strict mode db.[/quote] FYI the userguide is still wrong - it either needs a default value for 'userdata' - or allow for NULL. Database Error loading my ci_session - El Forum - 11-08-2010 [eluser]Derek Allard[/eluser] I fixed it here, so when CI2 goes out it'll be a part of that. |