Database Error loading my ci_session |
[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
[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.
[eluser]InsiteFX[/eluser]
Code: -- InsiteFX
[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-gui...sions.html
[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.
[eluser]Derek Allard[/eluser]
Oh snap! Right you are. Updating userguide example for strict mode db.
[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.
|
Welcome Guest, Not a member yet? Register Sign In |