Welcome Guest, Not a member yet? Register   Sign In
Config variable only returning first letter?
#1

[eluser]joehopkins[/eluser]
Hi,

I'm setting a variable to be used globally across the site so I thought I'd load a config file:

config/Sitevariables.php

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

$config['site_name'] = 'BAA CRM';

config/autoload.php

Code:
$autoload['config'] = array('email', 'Sitevariables');

anything.php

Code:
echo $this->config->item('Sitevariables', 'site_name')

Returns 'B'. Just the first letter.

What is going on?!!!! Why doth CodeIgniter forsake me so?

Thanks,

Joe
#2

[eluser]JonoB[/eluser]
Please read http://ellislab.com/codeigniter/user-gui...onfig.html carefully.

You have
Code:
echo $this->config->item('Sitevariables', 'site_name')
the wrong way around.

I am also note sure if autoloading the config creates the config as a separate array. You may have to load it manually instead
Code:
$this->config->load('Sitevariables', TRUE);

Lastly, I'd suggest lowercase everything/
#3

[eluser]InsiteFX[/eluser]
If it uses $config[] it will load!

Code:
$this->config->load('Sitevariables');

echo $this->config->item('site_name');

InsiteFX
#4

[eluser]joehopkins[/eluser]
Thanks Guys,

JonoB - that didn't work for some reason, but I have lowercased it!!!! Smile That will be my mantra from now on.

InsiteFX - that did work (kudos):

I don't need

Code:
$this->config->load['etc'];

so just

Code:
$this->config->item('site_name');

works, as long as I have

Code:
$autoload['config'] = array('sitevariables', 'etc.');

In the autoload.php file. ( JonoB - note the lower case Smile )

It seems the answer was more simple than I thought. I still wonder why it was only outputting the first letter, but it doesn't matter any more.

Many thanks guys! You'll both go to Heaven.

Joe




Theme © iAndrew 2016 - Forum software by © MyBB