CodeIgniter Forums
MySQL Connection / PHP complaints - 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: MySQL Connection / PHP complaints (/showthread.php?tid=2506)



MySQL Connection / PHP complaints - El Forum - 08-09-2007

[eluser]danfloun[/eluser]
Hi,
I've just installed the latest xampp and have installed Code Igniter which so far is looking good. I've run through the tutorials to get to grips with the basics but I've hit a minor problem

Although I seem to have no connection failures I get an error at the top of my index.php when trying to access the MySQL database.

The error:

Code:
A PHP Error was encountered

Severity: Notice

Message: Use of undefined constant database - assumed 'database'

Filename: config/autoload.php

Line Number: 41

My test server:

Apache: 2.2.4
PHP: 5.2.3
MySQL: 5.0.45


My autoload.php

Code:
$autoload['libraries'] = array(database);

My database.php

Code:
$active_group = "default";

$db['default']['hostname'] = "localhost";
$db['default']['username'] = "root";
$db['default']['password'] = "mypassword";
$db['default']['database'] = "blog";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['active_r'] = TRUE;
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";

Thanks for any help


MySQL Connection / PHP complaints - El Forum - 08-09-2007

[eluser]Phil Sturgeon[/eluser]
This a PHP syntax warning. You are not making database a string, instead its a constant which it assumes to be a string.

Use:

Code:
$autoload['libraries'] = array('database');



MySQL Connection / PHP complaints - El Forum - 08-09-2007

[eluser]danfloun[/eluser]
DOH!

That sorted it, thanks for pointing out the obvious.
It has been a long night lol..

Thanks again.