0

I am following a beginner's tutorial for CodeIgniter, but I can't get the view to load correctly because I have a database connection error. I have followed everything step-by-step, and gone through it again several times, but not been able to fix it. Could someone please help me, or at least explain why this is happening?

Here is the database configuration I currently have setup:

$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = 'root';
$db['default']['database'] = 'helloworld';
$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';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

I've also autoloaded the database library with the following code:

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

I would also like to point out that I am using PHP version 5.3.13. I not sure if the version of PHP would affect my code, so I added it anyway.

The exact error I'm getting is:

A Database Error Occurred

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

Filename: C:\wamp\www\CI\system\database\DB_driver.php

Line Number: 124
JaPerk14
  • 1,664
  • 3
  • 24
  • 32
  • That means that you have the wrong database credentials. Check again for the username and password or the database name to be sure that are correct. – mallix Mar 03 '13 at 20:04
  • The error indicates your login, hostname, or database name are not correct. – kittycat Mar 03 '13 at 20:06
  • I'm pretty sure I have the hostname & db right, which just leaves the username / password. What is the default username / password for phpmyadmin? – JaPerk14 Mar 03 '13 at 20:08
  • Are you working local? try user name root and password leave it blank: $db['default']['username'] = 'root'; $db['default']['password'] = ''; – Fabio Antunes Mar 03 '13 at 20:10
  • 1
    @JaPerk14 Please simply delete the question if you just had the wrong password, no one can benefit from this post. – Wesley Murch Mar 03 '13 at 21:53
  • I was also wondering, and he followed everything step by step. – Steward Godwin Jornsen Mar 03 '13 at 22:22

2 Answers2

2
$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root'; // default username if has not been set in phpmyadmin
$db['default']['password'] = ''; //leave it blank if has not been set in phpmyadmin
$db['default']['database'] = 'helloworld'; // this is your database name
$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';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
user2046410
  • 117
  • 4
  • 15
1

you might have tried to import the project to work space.Instead try to traverse to the project folder through project explorer

KRG
  • 655
  • 7
  • 18