0

I have created a db file in my directory of the webpage with name my_db.db. I am using phpstorm and the db file is correctly configured.

Now I am finding problems on what connection settings to set in codeigniter so that I can connect but I get a database error:

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

Filename: core/CodeIgniter.php

Line Number: 518`

My connection settings from codeigniter are as follows:

$db['default'] = array(
    'dsn'   => '/db/my_db.db',
    'hostname' => 'localhost',
    'username' => '',
    'password' => '',
    'database' => 'my_db',
    'dbdriver' => 'mysqli',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

This is a local site and thus no username and password are available for the the connection that is why there is nothing.

How can I correctly connect as these settings are not correct. The structure of where the db is found relative to the index.php is as follows: index.php db/my_db.db

Cœur
  • 37,241
  • 25
  • 195
  • 267
Combinu
  • 882
  • 2
  • 10
  • 31
  • There is nothing duplicate. The other question refers to a different problem – Combinu May 11 '19 at 20:42
  • turn db debug on (set to true), and double check your local env doesn't require a username. i run xampp and i must use `root` as username but no password. also i've never seen dsn used as a file. typically it is like: `$db['default']['dsn'] = 'pgsql:host=localhost;port=5432;dbname=database_name';` although i would just leave it **empty** and let ci do it for me – Alex May 11 '19 at 22:46

0 Answers0