0

The code is connect but the database group is invalid i.e. the code doesnt connect with the database because the setting in database.php file is invalid. where do we look for the error and how to resolve this.

You have specified an invalid database connection group (db) in your config/database.php file.

This file show error but not specified to where is error

config/database.php code below: 


$db['default'] = array(
    'dsn'   => 'pgsql:host=localhost;port=5432;dbname=success_story',
    'hostname' => 'localhost',
    'username' => 'puneetchhabra',
    'password' => 'shambhu',
    'database' => 'success_story',
    '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
);

The database.php file code is show what seems to be the error.

browser has this error unable to connect.

Message: pg_connect(): Unable to connect to PostgreSQL server: missing "=" `after "localhost" in connection info string`

Be kind and suggest.

Thanks.

6
  • What's your $active_group ? in your database.php you should declare $active_group = 'default'; Commented Oct 7, 2019 at 10:29
  • $active_group = 'default'; already coded Commented Oct 7, 2019 at 10:37
  • i don't think so - because Codeigniter tells you it is $active_group = 'db'; (according to your error message) Commented Oct 7, 2019 at 10:40
  • man its already coded Commented Oct 7, 2019 at 10:42
  • i didnt quite get you you mean instead of 'default' i write 'db'. is that what you mean ? Commented Oct 7, 2019 at 10:52

1 Answer 1

1

try this

$db['default'] = array(
    'dsn'   => 'localhost',
    'hostname' => 'localhost',
    'username' => 'puneetchhabra',
    'password' => 'shambhu',
    'database' => 'success_story',
    'dbdriver' => 'postgre', # or PDO
    'port' => '' #ex 5433
);

make sure

  1. You can connect outside the application (pgadmin)
  2. In php.ini enable extenxtion php_pdo_pgsql (for pdo) and php_pgsql(for postgre).
Sign up to request clarification or add additional context in comments.

4 Comments

the error still remains i'll update the php.ini and enable extension
restart the xamp/LAMP
hello again, so the code for the following extension is enable; conf/php.ini. where does the problem exist ?
so i narrowed it down to the error is Message: pg_connect(): Unable to connect to PostgreSQL server: missing "=" after "localhost" in connection info string

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.