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.
Related
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.
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/
This is the error:
A Database Error Occurred
Error Number:
select a.FOLIO, a.direccion, b.DESC_COLONIA, C.DESC_MPIO
from emergencias#db1 a INNER JOIN AMSGEOCODING#db1 Z ON A.FOLIO=Z.FOLIO inner join cat_colonia#db1 b on A.CVE_COL=b.cve_col and A.CVE_MPIO=b.cve_mpio and A.CVE_ent=b.cve_ent INNER JOIN CAT_MPIO#db1 C ON C.CVE_MPIO =A.CVE_MPIO AND C.CVE_ENT=A.CVE_ENT WHERE a.folio>=8782583 and z.LATITUD =0 and z.LONGITUD<>-1
Filename: C:\wamp\www\myapp\system\database\DB_driver.php
Line Number: 331
What could be wrong with this?
this is my C:\wamp\www\myapp\application\config\database.php
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost/orcl',
'username' => 'local',
'password' => 'password',
'database' => 'orcl',
'dbdriver' => 'oci8',
'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
);