Codeigniter + Lampstack - Unable to connect to your database - php

i have this on my localhost and it works perfectly fine.
but when i put it on a server i configured the database settings correctly
here is my config/database.php
$db['default'] = array(
'dsn' => '',
'hostname' => '111.111.1.111', //sample host
'username' => 'root',
'password' => 'password',
'database' => 'mydatabase',
'dbdriver' => 'mysqli',
'port' => '1234',
'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' => FALSE
);
but all i got was the error
Unable to connect to your database server using the provided settings.
Filename: third_party/MX/Base.php
Line Number: 55
what is the problem?

Related

CodeIgniter on App Engine time out whe concting to MySQL

I am hosting a CodeIgniter API on GCP App Engine and I cant connect to the GCP Cloud SQL. I create the instance and database, but when I try to conect via CI I got a timeout message
error screen
My databse config on CI is:
$db['default'] = array(
'dsn' => 'mysql:unix_socket=/instance_name/instancia;dbname=project_name',
'hostname' => 'http://00.000.00.00',//here i put the public ip from the sql instance
'username' => 'user',
'password' => 'passwd',
'database' => 'projeto',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => yes,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
I've been banging my head on this for a while, myself, and finally cracked it! Here's what my db config looks like:
$db['default'] = array(
'dsn' => '',
'hostname' => '/cloudsql/PROJECT-NAME:REGION:DATABASE',
'username' => 'USERNAME',
'password' => 'PASSWORD',
'database' => 'DATABASE_NAME',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
// 'db_debug' => TRUE,
'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 important bits are that the dsn is empty and the hostname is the full path to the unix socket. The rest of it should be about the same.
Hope that helps you, too!

Unable to Connect SQL server with Codeigniter

I Developed Codeigniter app with SQL server connection. it is properly connected when using PHP 5.6 on windows 7 PC, but same application not working on windows 10 with same PHP version. showing the error
$db['default'] = array(
'dsn' => '',
'hostname' => '192.168.0.241',
'username' => 'sa',
'password' => 'mypw',
'database' => 'dbsrver',
'dbdriver' => 'sqlsrv',
'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
);
You might have some error in configuration. Make sure you have correctly configure database.
In application/config/databse.php
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => 'write password if any otherwise leave it empty',
'database' => 'Your_Database_Name',
'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
);

Unable to connect using PHP 7.2.4 with SQL Server 2008

I have newly installed PHP 7.2.4 and Apache 2.4 on windows server 2008 r2. Everything done; i have set the paths, but problem is that when i configuring my PHP file for the connection, it gives me an error unable to connect with database. I am using codeIgniter 3.1.8.
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'database_name',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => TRUE,
'db_debug' => TRUE,
'cache_on' => FALSE
)
define('ENVIRONMENT','development'); This is a Codeigniter 3, database.php (non SSPI) snippet example for MSSQL 2008R2:
define('ENVIRONMENT','development');
$db['test1'] = array( 'dsn' => '',
'hostname' => 'MY_MSSQL_DB_FQDN\i1,10001',
'username' => 'somemssqluser',
'password' => 'somemssqlpassword',
'database' => 'somedbname',
'dbdriver' => 'sqlsrv',
'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
);

configuration MSSQL with PHP 5.6.x(xamp) using code-igniter

I have an issue while configuration MSSQL DATABASE with my codeigniter. I have placed these below file in xamp/php/ext:
php_pdo_sqlsrv_56_ts.dll
php_sqlsrv_56_ts.dll
php_sqlsrv_56_nts.dll
php_pdo_sqlsrv_56_nts.dll
I have also ensured to extended dll files in php.ini(I have tested both ts and nts separately)
Below is my database file in codeigniter
$db['default'] = array(
'dsn' => '',
'hostname' => 'tcp:xyz.database.windows.net',
'username' => '****',
'password' => '****',
'database' => '****',
'dbdriver' => 'sqlsrv', // i have use also mssql
'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
);
ERROR
Unable to connect to your database server using the provided settings.
Filename: C:/xampp/htdocs/sqlsrv/system/database/DB_driver.php
Line Number: 436
I am using PHP Version 5.6.14 in XAMP .
imho you should use a dsn for this - since you also installed the pdo driver you can try the following (1433 is the port - i don't know yours):
$db['default'] = array(
'dsn' => 'sqlsrv:server=xyz.database.windows.net,1433;Database=****',
'hostname' => '',
'username' => '****',
'password' => '****',
'dbdriver' => 'pdo', // i have use also mssql
'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
);

mssql_connect(): Unable to connect to server: (192.168.0.139)\PKSRV\SQLSERVER2008 codeigniter error

I am using codeigniter 3 and sql server 2008. i want remote connection with sql server database. But codeigniter is giving error or provided server and error is as my question title.
can any one help regarding to this. My database setting is as follow
$db['default'] = array(
'dsn' => '',
'hostname' => '(192.168.0.139)\PKSRV\SQLSERVER2008',
'username' => 'xxxxx',
'password' => 'xxxxx',
'database' => 'xxxxx',
'dbdriver' => 'mssql',
'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
);

Categories