Connect Codeigniter to Oracle 11g

Please, help! I can not connect codeigniter to Oracle I'm trying to connect Codeigniter to Oracle 11g, here are my settings

Settings in database.php: $active_group = 'default'; $active_record = TRUE; $db['default']['hostname'] = "//localhost/"; $db['default']['username'] = 'xxxxxxx'; $db['default']['password'] = 'xxxxxxx'; $db['default']['database'] = 'orcl'; $db['default']['dbdriver'] = 'oci8'; $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; 

Note. I added the variable C: \ instantclient_11_2 to the environment variable in PATH.

 oracle port number: oracle hostname: Home-pc database name: orcl 

Only when I run the CodeIgniter login code does it display this error message:

 A Database Error Occurred Unable to connect to your database server using the provided settings. Filename: D:\xampp\htdocs\ci\system\database\DB_driver.php Line Number: 124 

But I can connect to Oracle when I run simple PHP code, for example:

 <?php $conn = oci_connect("xxxxxx", "xxxxxx",""); if (!$conn) { echo "Not connected!"; } else echo "yahooooooooo!!!!!!!!!!"; ?> 

Result: yahooooooooo !!!!!!!!!!

+6
source share
4 answers

In your config database.php, do the following changes

 $active_group = 'default'; $active_record = TRUE; $tnsname = '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))'; $db['default']['hostname'] = $tnsname; $db['default']['username'] = 'XXXXXX'; $db['default']['password'] = 'XXXXX'; $db['default']['database'] = ''; $db['default']['dbdriver'] = 'oci8'; $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; 
+3
source

change default to XE

 $active_group = 'XE'; $active_record = TRUE; $tnsname = '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))'; $db['XE']['hostname'] = $tnsname; $db['XE']['username'] = 'XXXXXX'; $db['XE']['password'] = 'XXXXX'; $db['XE']['database'] = ''; $db['XE']['dbdriver'] = 'oci8'; $db['XE']['dbprefix'] = ''; $db['XE']['pconnect'] = TRUE; $db['XE']['db_debug'] = TRUE; $db['XE']['cache_on'] = FALSE; $db['XE']['cachedir'] = ''; $db['XE']['char_set'] = 'utf8'; $db['XE']['dbcollat'] = 'utf8_general_ci'; $db['XE']['swap_pre'] = ''; $db['XE']['autoinit'] = TRUE; $db['XE']['stricton'] = FALSE; 
+1
source

try to do this change the host name to http://localhost:1521:orcl you are assigned the database name as orcl , by default orcl is the default orcl identifier. try creating a new user or database and make changes to the database configuration.

0
source

Make sure the php_oci8_11g.dll extension php_oci8_11g.dll loaded in php.ini

0
source

All Articles