Welcome Guest, Not a member yet? Register   Sign In
Newbie starting out - can't connect to database.
#1

[eluser]überfuzz[/eluser]
Hi all!

I'm just starting to learn, or should I write, mess about with code igniter. Seems to be just dandy. However, I can't connect to the database. I tried to auto-load it using log-in info thats working in phpmyadmin and the autoload-file
Code:
$autoload['libraries'] = array('database');
No luck! Every time I try it there's only a error-message:
Quote:A Database Error Occurred

Unable to connect to your database server using the provided settings.

When I don't load the database in autoload.php and push a hard coded array from the model to the controller everything is honky dory.

I guess it's just a newbie mistake. Someone please help me...
#2

[eluser]Dam1an[/eluser]
What have you go in the database config file? (/system/application/config/database.php)
#3

[eluser]überfuzz[/eluser]
I altered some info in this post.
Code:
$active_group = "default";
$active_record = TRUE;


$db['default']['hostname'] = "localhost";
$db['default']['username'] = "ma_____man"; //altered
$db['default']['password'] = "BEEEP";      //altered
$db['default']['database'] = "ma_____man"; //altered
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";
#4

[eluser]Dam1an[/eluser]
Are other libraries which get auto loaded working as expected? (You may need to add one to test it)
Trying to narrow down where the problem occurs, cause I've never come accross anything like this (I seem to be luck and avoid such issues Smile)
#5

[eluser]überfuzz[/eluser]
[quote author="Dam1an" date="1240358034"]I seem to be luck and avoid such issues Smile[/quote]

Are you sure it's all luck? ;-)

Suggestions on what libraries should I try to start then? Could it be that I can't open them, wrong path..?

An other question, is it possible to get a more precise error message maybe even a debug?
#6

[eluser]Dam1an[/eluser]
Well it might not all be luck, but things just seem to work for me when they're supposed to, and don't when I make a stupid mistake lol

I doubt the library issue is an incorrect path, as libraries such as the loader get loaded by CI, so that would have thrown an error

Try autoloading the calender class and then doing
Code:
echo $this->calendar->generate();

As for getting more error data, I don't know, as have never needed it, although there are some logging settings in the config file, maybe try tweaking them
#7

[eluser]überfuzz[/eluser]
[quote author="Dam1an" date="1240362739"]I doubt the library issue is an incorrect path, as libraries such as the loader get loaded by CI, so that would have thrown an error

Try autoloading the calender class and then doing
Code:
echo $this->calendar->generate();
[/quote]

I tried and it printed out the calendar - nicely. Like you said nothing wrong with the path.
#8

[eluser]Dam1an[/eluser]
Seeing as you're new to CI, I'm assuming you're using the latest version (1.7.1)?
Did you have this problem straight away from a clean install, or did you make other tweaks/changes before you realise this problem?




Theme © iAndrew 2016 - Forum software by © MyBB