-1

This is my connection:

Using CodeIgniter

$db['mysql'] = array(   
'dsn' => 'mysql:host=SOMEHOSTNAME;dbname=SOMEDATABASE',
'hostname' => 'SOMEHOSTNAME',
'username' => 'SOME USER',
'password' => 'password',
'database' => 'SOME DATABASE',
'dbdriver' => 'pdo',

);

This is my localhost conection

$db['mysql'] = array(
'dsn'   => 'mysql:hostname=localhost; dbname=1410inventory',
'hostname' => '',
'username' => 'root',
'password' => '',
'database' => '',
'dbdriver' => 'pdo',

);

My log pulls this:

ERROR - 2018-07-23 19:36:18 --> PDO: Invalid or non-existent subdriver

Please Help Edit:This is a test DB.

  • Hi German Mendieta. Do **NOT** post database connection details on the web!!! I removed what was in the question. I *strongly* suggest you flush all data in there and put back some backup you have (you have one right?). God knows what is in that database now! – Nic3500 Jul 23 '18 at 22:49
  • As for your question, where does the code run? Is it in the same hoster environment as the database? Are remote connections allowed by this provider? The ones I use will not allow any remote connection to their database, only locally running code. – Nic3500 Jul 23 '18 at 22:50
  • And search is your friend: https://forum.codeigniter.com/archive/index.php?thread-65419.html and https://stackoverflow.com/questions/32836797/codeigniter-3-1-pdo-mysql-error-number-3d000-1046-no-database-selected and others. – Nic3500 Jul 23 '18 at 22:52

1 Answers1

0

I hardly recommend you not to use PDO driver since it is slower and you don't have all the codeigniter query builders (more info here). Instead I recommend you use msqli driver, and it would look like this:

$active_group = 'default';
$query_builder = TRUE;

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'username' => 'SomeUserName',
    'password' => 'SomePass',
    'database' => '1410inventory',
    'dbdriver' => 'mysqli',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'development'), //change to production when needed
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

If you're still wanting to use PDO just remove the last comma after 'dbdriver' => 'pdo', like this 'dbdriver' => 'pdo' since it's the last element of your array there's no need to put an extra comma and change hostname for host so your localhost connection should look like

$db['mysql'] = array( 
'dsn'    => 'mysql:host=host_name;dbname=1410inventory',
'username' => 'usr',
'password' => 'pw',
'database' => '1410inventory',
'dbdriver' => 'pdo' );
Eduardo Palacio
  • 301
  • 1
  • 10