I am looking for a solution that will allow me to connect to MS SQL through an ODBC that uses Windows Authentication. I have tested and verified all of the rest of the code by using a standard ODBC connection that requires a user/pass. Below are the settings that work with that ODBC and the settings I have tried on the Windows Authentication ODBC.
Working database.php settings -standard user/pass connection
$active_group = 'jf2';
$active_record = TRUE;
$db['jf']['hostname'] = 'system DSN name';
$db['jf']['username'] = 'db_user';
$db['jf']['password'] = 'db_pass';
$db['jf']['database'] = 'db_name';
$db['jf']['dbdriver'] = 'odbc';
$db['jf']['dbprefix'] = '';
$db['jf']['pconnect'] = TRUE;
$db['jf']['db_debug'] = TRUE;
$db['jf']['cache_on'] = FALSE;
$db['jf']['cachedir'] = '';
$db['jf']['char_set'] = 'utf8';
$db['jf']['dbcollat'] = 'utf8_general_ci';
$db['jf']['swap_pre'] = '';
$db['jf']['autoinit'] = TRUE;
$db['jf']['stricton'] = FALSE;
non-working database.php settings - Windows Auth attempt
$active_group = 'jf1';
$active_record = TRUE;
$db['jf1']['hostname'] = 'system DSN name';
$db['jf1']['username'] = '';
$db['jf1']['password'] = '';
$db['jf1']['database'] = 'db_name';
$db['jf1']['dbdriver'] = 'odbc';
$db['jf1']['dbprefix'] = '';
$db['jf1']['pconnect'] = TRUE;
$db['jf1']['db_debug'] = TRUE;
$db['jf1']['cache_on'] = FALSE;
$db['jf1']['cachedir'] = '';
$db['jf1']['char_set'] = 'utf8';
$db['jf1']['dbcollat'] = 'utf8_general_ci';
$db['jf1']['swap_pre'] = '';
$db['jf1']['autoinit'] = TRUE;
$db['jf1']['stricton'] = FALSE;
Specifically, I am unsure what will go into the user/pass fields. The error is below:
A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: C:\wamp\www\CodeIgniter_2.1.2\boss_table\system\database\DB_driver.php
Line Number: 124
Thanks for your help.
$db['jf1']['hostname'] = 'system DSN name';
$db['jf']['username'] = '';
$db['jf']['password'] = '';
$db['jf1']['database'] = 'db_name';
You are setting the username and password key on the jf database group instead of on the jf1 group.
$db['jf1']['hostname'] = 'system DSN name';
$db['jf1']['username'] = 'insert_username';
$db['jf1']['password'] = 'insert_password';
$db['jf1']['database'] = 'db_name';
Related
CodeIgniter sessions are not working on the live server ?
$config["sess_driver"] = "files";
$config["sess_cookie_name"] = "ci_session";
$config["sess_expiration"] = 7200;
$config["sess_save_path"] = NULL;
$config["sess_match_ip"] = FALSE;
$config["sess_time_to_update"] = 300;
$config["sess_regenerate_destroy"] = FALSE;
Using XAMPP for running codeigniter getting blank screen everytime in localhost. Other codeigniter project working well
$db['default']['username'] = "";
$db['default']['password'] = "";
$db['default']['database'] = "";
// The following values can probably stay the same.
$db['default']['hostname'] = "";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = FALSE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";
$active_group = "default";
$active_record = TRUE;
A blank screen usually means you have missed a " ; " someplace. I would say check your syntax completely. The missing ; might be in your view, controller or in the model. Almost any syntax error can bring you a blank screen
I’m using PDO driver to access MySQL database. Everything is working OK on that part. My database.php looks like this:
$active_group = 'default';
$active_record = FALSE;
$db['default']['hostname'] = 'mysql:host=127.0.0.1:3386';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'mydatabase';
$db['default']['dbdriver'] = 'pdo';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
I don’t use Active Record..
The problem occurred when I auto-loaded session library and set it to use database. I created table in my database, and on first visit to site, a record gets inserted into session table. No problem there.
An error occurs on subsequent visits to the site. I’m getting following:
Fatal error: Call to undefined method CI_DB_pdo_driver::where() in P:\Git\TengWebsite\system\libraries\Session.php on line 201
set $active_record = TRUE;
$active_group = 'default';
$active_record = TRUE;
Note: that some CodeIgniter classes such as Sessions require Active Records be enabled to access certain functionality.
its clearly stated here CodeIgniter Doc
When I try to connect Amazon EC2 instance with RDS instance using codeigniter on EC2, I get a message: Unable to connect to your database server using the provided settings. But when using a classic dedicated server with same parameters to connect to RDS, connection is successful.
$db['default']['hostname'] = 'xxxxxxx';
$db['default']['username'] = 'xxxxx';
$db['default']['password'] = 'xxxxxxx';
$db['default']['database'] = 'xxxxxxx';
$db['default']['dbdriver'] = 'mysqli';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['port'] = 3306;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
$db['default']['ssl_set'] = TRUE;
$db['default']['ssl_key'] = NULL;
$db['default']['ssl_cert'] = NULL;
$db['default']['ssl_ca'] = realpath('./mycertificate.pem');
$db['default']['ssl_capath'] = NULL;
$db['default']['ssl_cipher'] = NULL;
If you're able to access your RDS from another server I would say your Security Groups may be stopping access between your EC2 and RDS. Are they inside separate private subnets in a VPC?
If so you should assign inside the security groups the ability for each instance to access and communicate with each other on port 3306 (you can actually assign a Security Group as a source in the Security Group tabs which is awesome!)
If not, what does your environment look like between the EC2 and the RDS?
I'm connecting to an Access DB via mdbtools on a Linux system and on running any query via Active Record it returns an empty result. No errors or anything to show in the logs. Any ideas ? It connects to the database without a hitch and I have no problem accessing the tables or running queries with the default PHP method (e.g. odbc_exec(...)).
The DB Connection looks like this:
$db['access']['hostname'] = 'MyDB';
$db['access']['username'] = '';
$db['access']['password'] = '';
$db['access']['database'] = 'MyDB';
$db['access']['dbdriver'] = 'odbc';
$db['access']['dbprefix'] = '';
$db['access']['pconnect'] = TRUE;
$db['access']['db_debug'] = TRUE;
$db['access']['cache_on'] = FALSE;
$db['access']['cachedir'] = '';
$db['access']['char_set'] = 'utf8';
$db['access']['dbcollat'] = 'utf8_general_ci';
$db['access']['swap_pre'] = '';
$db['access']['autoinit'] = TRUE;
$db['access']['stricton'] = FALSE;
The odbc.ini looks like:
[MyDB]
Description = My Database
Driver = /usr/lib64/libmdbodbc.so
Database = /var/database/MyDB.mdb
Connecting with:
$this->access = $this->load->database('access', TRUE);
I do not have microsoft access database to test with the following configuration, but I think this should be able to give you an idea to experience with different configuration. You can specify data source name in your configuration and I collected the settings from codeigniter forum and merge with yours.
$db['access']['hostname'] = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=/var/database/MyDB.mdb";
$db['access']['username'] = "ADODB.Connection";
$db['access']['password'] = "";
$db['access']['database'] = "/var/database/MyDB.mdb";
$db['access']['dbdriver'] = "odbc";
$db['access']['dbprefix'] = "";
$db['access']['pconnect'] = TRUE;
$db['access']['db_debug'] = TRUE;
$db['access']['cache_on'] = FALSE;
$db['access']['cachedir'] = "";
$db['access']['char_set'] = "utf8";
$db['access']['dbcollat'] = "utf8_general_ci";
$db['access']['swap_pre'] = "";
$db['access']['autoinit'] = TRUE;
$db['access']['stricton'] = FALSE;