7

I develloping a web-based application with codeigniter and when I try to connect to my oracle entreprise 9g database the framework send me this error:

    A PHP Error was encountered

Severity: Notice

Message: Use of undefined constant OCI_COMMIT_ON_SUCCESS - assumed 'OCI_COMMIT_ON_SUCCESS'

Filename: database/DB.php

Line Number: 142

I tried different method to connect (classic, oracle specific). There is my config/database.php file.

$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=*xxx.xxx.xxx.xxx*)(PORT=1521))(CONNECT_DATA=(SID=*DB_NAME*)))';
$db['default']['username'] = '*username*';
$db['default']['password'] = '*password*';
$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;

I think it's not a connection error, can you help me?

Bassochette
  • 166
  • 1
  • 1
  • 13

1 Answers1

13

OCI_COMMIT_ON_SUCCESS is a constant declared in the Oracle PHP extension. Are you sure you have that installed correctly? Is it enabled in php.ini? Can you confirm that you can connect to the database manually with oci_connect?

If you don't have the extension, then you'll need to install it. There is a list of steps I generally take to debug the installation here.

I'm not sure what the value of OCI_COMMIT_ON_SUCCESS is, but you might be able to fake it with your own define, if it comes to that.

Community
  • 1
  • 1
cwallenpoole
  • 79,954
  • 26
  • 128
  • 166
  • 1
    Thank you, it came from the activation of the extension in php.ini. – Bassochette Jul 20 '11 at 08:56
  • @cwallenpoole: I have installed Oracle Client. And in my php.ini I have enabled: php_oci8.dll, php_oci88_11g.dll and php_pdo_oci.dll I checked oci_connect() function but it become "Fatal error: Call to undefined function oci_connect()". How to fix it, please? How to install it right ? – Tien Hoang Nov 19 '14 at 04:57
  • 1
    @TienHoang Are you sure you're using the right version of php.ini, some instances of PHP have two different ini files on the same machine (I, for one, am using a Mac, which has a different ini for CLI and for Apache). – cwallenpoole Nov 19 '14 at 15:40
  • "Undefined function oci_connect" means that you do not have the OCI extension installed in any case. – cwallenpoole Nov 19 '14 at 15:40
  • 1
    @cwallenpoole: Yeah, I found my problem. I use both php_oci8.dll and php_oci8_11g.dll and it not fit my system. Thank you. – Tien Hoang Nov 21 '14 at 10:22