2

I am working on CodeIgniter. While connecting the database, I got following error:

You have not selected a database type to connect to.

My $db settings:

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = 'mypass';
$db['default']['database'] = 'mydatabase';
$db['default']['mysqli'] = '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;

My CodeIgniter version is 2.1.2.

I have selected the database as shown above.

1
  • 1
    hi, if you are working with ci2.1.2, first this arrar is wrong, because, below $db['default']['mysqli'] = 'mysql'; must be $db['default']['dbdriver'] = 'mysqli';`` Commented Jun 30, 2017 at 16:21

1 Answer 1

2

you are not initializing your DB driver in your file

Try this

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'dbName';
$db['default']['dbdriver'] = 'mysqli';
$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;
Sign up to request clarification or add additional context in comments.

2 Comments

I have the same error: You have not selected a database type to connect to.$db['default']['dbdriver'] = 'mysqli';
basically I was trying to connect to anotherDB dynamically, querying the database table from firstDB. and that was making problem. Now its ok. thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.