CodeIgniter Forums
Unable to write to config file - 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: Unable to write to config file (/showthread.php?tid=5158)



Unable to write to config file - El Forum - 01-09-2008

[eluser]Dsyfa[/eluser]
Hi,

I have some fields in my config that I would like to modify dynamically.
Code:
/*
|--------------------------------------------------------------------------
| Global Meta Data
|--------------------------------------------------------------------------
*/
$config['md_keywords'] = 'lorem, ipsum';
$config['md_description'] = 'Lorem - Ipsum.';

This is the code that I'm using to modify the above fields.
Code:
$data[ 'keywords' ] = $this->input->post( 'keywords', true );
$this->config->set_item( 'md_keywords', $data[ 'keywords' ] );

Where am I going wrong?

Thanks


Unable to write to config file - El Forum - 01-09-2008

[eluser]xwero[/eluser]
The set_item method doesn't write to the config file itself. It only overwrites the fetched value that has been set in the file.

If you want some input to be remembered you better put it in the session data. If you want some preferences remembered longer you add it to the database and overwrite default config values from the database.

You have to look at the config file variables as constants. They should only be changed when it affects the whole application.


Unable to write to config file - El Forum - 01-09-2008

[eluser]Dsyfa[/eluser]
[quote author="xwero" date="1199893606"]The set_item method doesn't write to the config file itself. It only overwrites the fetched value that has been set in the file.

If you want some input to be remembered you better put it in the session data. If you want some preferences remembered longer you add it to the database and overwrite default config values from the database.

You have to look at the config file variables as constants. They should only be changed when it affects the whole application.[/quote]

Thanks! Learned sumthing new 2day!