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?
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.
Related
after updating my myqsli driver function i keep seeing this
A PHP Error was encountered
Severity: Warning
Message: mysqli_connect(): (HY000/2002): No such file or directory
Filename: mysqli/mysqli_driver.php
Line Number: 110
Backtrace:
File: /Applications/XAMPP/xamppfiles/htdocs/alcantara/application/controllers/Vendor.php
Line: 11
Function: __construct
File: /Applications/XAMPP/xamppfiles/htdocs/alcantara/index.php
Line: 274
Function: require_once
I don't know if there is anything I have to install again, I am using mac os.
Here is my database file
*/
$active_group = 'default';
$query_builder = TRUE;
$db['default']['hostname'] = '127.0.0.1';
$db['default']['username'] = 'testing';
$db['default']['password'] = '';
$db['default']['database'] = 'database';
$db['default']['dbdriver'] = 'mysqli';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = FALSE;
$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;
$db['default']['socket'] = 'mysql:unix_socket=/cloudsql/project_id:xxx';
I finally solved it buy updating my codeigniter mysqli connect function with the new one i downloaded from the website..
I have noticed some unexpected behavior while connecting MySQL Codeigniter
Here is scenario:
-> I configured database library for autoload. (config/autoload.php)
$autoload['libraries'] = array('database', 'session');
-> But after configuring that, I can't open anything. I mean to say, Controller or View.
Have I done something wrong?
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = 'password';
$db['default']['database'] = 'myfamilyfirst';
$db['default']['dbdriver'] = 'mysql';
$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'] = FALSE;
$db['default']['stricton'] = FALSE;
I tried to set $db['default']['autoinit'] = TRUE; to $db['default']['autoinit'] = FALSE;
Now I can open the pages but unable to connect the database.
Please help.
Probably you are using new xampp or wamp. So it will not support mysql.
Change this
$db['default']['dbdriver'] = 'mysqli'; # Change
In codeignator latest version we need to connect database using Mysqli. So in database file you need to give database driver as mysqli like this,
$db['default']['dbdriver'] = 'mysqli';
New codeignator version have mysqli dbdriver. If we have add mysql instated mysqli then shows following error.
Message: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead
Correct way is : $db['default']['dbdriver'] = 'mysqli';
Please make sure that your database username and password matches. Sometimes, these little things matters a lot.
I'm encountering an error every time I'm connecting to my MS SQL 2005 database using CodeIgniter framework, I'm using PHP 5.6.8 version.`
"Fatal error: Call to undefined function sqlsrv_connect() in C:\xampp\htdocs\my_website\system\database\drivers\sqlsrv\sqlsrv_driver.php
on line 76"
I've already added dll files php_pdo_sqlsrv_56_ts.dll and php_sqlsrv_56_ts.dll to ext folder and on my php.ini, and installed Microsoft SQL Native Client 2012,
this is my code in the sqlsrv_driver.php line 76 -> return sqlsrv_connect($this->hostname, $connection);
I already setup and installed all needed files but still I encounter this error, and NO sqlsrv in phpinfo(), so I created a sample php file to test if I will connect to my database w/out using a framework and its successfully connected in MS SQL database, However it doesn't if I used codeigniter.
Did I miss some code, configuration or software to install? Thanks for usual support!
This is my database.php
$db['default']['hostname'] = 'MY-PC\MSSQL2005';
$db['default']['username'] = 'sa';
$db['default']['password'] = 'password';
$db['default']['database'] = 'MYDB';
$db['default']['dbdriver'] = 'sqlsrv';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = FALSE;
$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 want to connect to sql server
my php version is 5.4 and i have MS SQL Server 2008 R2 and i use PHP Codeigniger 2.4
i change database.php config
$db['default']['hostname'] = '192.168.5.208';
$db['default']['username'] = 'xxx';
$db['default']['password'] = 'xxx';
$db['default']['database'] = 'xxx';
$db['default']['dbdriver'] = 'sqlsrv';
$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 download sqlsrv30.exe.
install it in php/ext
i add the following on the php.ini file:
extension=php_sqlsrv_54_ts.dll
i install Native Client 10
i change sqlsrv_driver.php in folder database-driver-sqlsrv to
function db_pconnect() {
//return $this->db_connect(TRUE);
return $this->db_connect(TRUE);
}
i also try add
db['default']['port'] = 1433;
but its still not working. I always encountered the ff. error:
A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: C:\xampp\htdocs\HRM\system\database\DB_driver.php
Line Number: 124
what should i do ? please help
this solves it
change $db['default']['db_debug'] = TRUE; to $db['default']['db_debug'] = FALSE;
and
change $db['default']['pconnect'] = TRUE; to $db['default']['pconnect'] = FALSE;
i am getting the following error :
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 346
my database.php is :
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'usertest';
$db['default']['password'] = '';
$db['default']['database'] = 'usertest';
$db['default']['port'] = '5433';
$db['default']['dbdriver'] = 'postgre';
$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;
What is the possible solution. I do not want to $db['default']['db_debug'] = FALSE;
as even after doing this i am still not able to connect to db.
EDIT :
Changed the port to 5432. still it doesnt work
Set Set $db['default']['pconnect'] = FALSE; and check once again.
Some database drivers (such as PDO, PostgreSQL, Oracle, ODBC) might
require a full DSN string to be provided. If that is the case, you
should use the ‘dsn’ configuration setting, as if you’re using the
driver’s underlying native PHP extension, like this:
$db['default']['dsn'] = 'pgsql:host=localhost;port=5432;dbname=database_name';
from official documentation of codeigniter
Try:
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = FALSE;
Check your db driver name. I am pretty sure it is "postgres" and not "postgre."