if i change dbdriver from mysqli to mysql it's working but not in mysqli
What would be the problem?
database.php - database config
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => '',
'password' => '',
'database' => '',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
Please make sure MySQLi Driver is installed and enabled in Apache.
There are three solutions for you
Make sure php-mysqli is installed and enable in apache.
Check System Directory of Codeigniter. If the mysql/mysqli directory not exist at that place then copy it from the fresh codeigniter.
Switch the driver from mysqli to pdo.
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => 'pgsql:host=localhost;port=3306;dbname=myproject',
'hostname' => 'localhost',
'username' => 'root',
'password' => '*******',
'database' => 'myproject',
'dbdriver' => 'pdo',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
You can follow the full tutorial from the reference article.
https://mytechnode.com/invalid-db-driver-in-codeigniter-mysqli/
Related
I have a data with VARCHAR2 data type in database(oracle) like this "Mary’s" but when I try to retrieve it using codeigniter it displays "Mary?s" It replaces the single quote with question mark(?). I'm also getting the same result with Chinese characters
The character set of my database is AL32UTF8.
I'm using codeigniter and odbc driver
Please help me to fix this problem
I already added this code in my view:
<?php header('Content-Type: text/html; charset=utf-8');?>
Here's my database configuration:
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => "test",
'hostname' => "",
'username' => 'test'
'password' => 'test123',
'database' => 'myShop',
'dbdriver' => 'odbc',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf-8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE,
I am trying to host a codeigniter project on heroku, using an external mysql database at db4free.net.
I have tried all I can to no avail but my last effort looks like this
$db['mysql'] = array(
'dsn' => 'mysql:hostname="db4free.net"; dbname=ravenstock',
'hostname' => '',
'username' => 'ravenstockadmin',
'password' => '**************',
'database' => '',
'dbdriver' => 'pdo',
'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
);
Please Try This...
'hostname' => '45.113.122.253:3306',
'username' => 'your server username',
'password' => 'your server password',
'database' => 'server database name',
'dbdriver' => 'pdo',
'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
in database.php
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'bd1',
'password' => 'pass3214',
'database' => 'db1',
'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
);
$db['conncetdbtest'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'db2',
'password' => 'pass123',
'database' => 'db2',
'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
);
in test.php in view
<?php
$DB2 = $this->load->database('conncetdbtest' , TRUE);
$querydb2 = $DB2 ->select('*')->get('test');
print_r($querydb2);
?>
When I run the the code , showing me Message: mysqli::real_connect(): (HY000/1045): Access denied for user 'db2'#'localhost' (using password: YES).
Do not able to solve . Please help me .
The following error occurred while running the URl of my codeigniter project with database in 000webhost, the configuration of the database is given below.
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'id4100798_skyloade_msd',
'password' => '******',
'database' => 'id4100798_skyloade_msd',
'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
);
it give the following error when we browse the url
error :
Message: Unable to locate the model you have specified: Data
URL:
https://medicalsociodoc.000webhostapp.com/SiteController
it is working fine on localhost.
I got this error :
Unable to connect to your database server using the provided settings.
Filename: C:/xampp/htdocs/soheil/system/database/DB_driver.php
Line Number: 436
but when I add below code inside database.php it prints ok :
echo '<pre>';
print_r($db['default']);
echo '</pre>';
echo 'Connecting to database: ' .$db['default']['database'];
$dbh=mysql_connect
(
$db['default']['hostname'],
$db['default']['username'],
$db['default']['password'])
or die('Cannot connect to the database because: ' . mysql_error());
mysql_select_db ($db['default']['database']);
echo '<br /> Connected OK:' ;
die( 'file: ' .__FILE__ . ' Line: ' .__LINE__);
my config :
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => '',
'password' => '',
'database' => 'soheil',
'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
);
Are you put your username on database? It maybe root user
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'soheil',
'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
);
Hope this help.