SQL Server 2008 R2 and Code Igniter Connection - php

I am using windows 8 and am trying to use sqlserver 2008 as my database.
I installed sql driver (SQLSRV31.exe) and I have
php_sqlsrv_54_ts.dll
php_sqlsrv_55_ts.dll
php_sqlsrv_54_nts.dll
php_sqlsrv_55_nts.dll
php_pdo_sqlsrv_54_ts.dll
php_pdo_sqlsrv_55_ts.dll
php_pdo_sqlsrv_54_nts.dll
php_pdo_sqlsrv_55_nts.dll
extracted to my php/ext. I have made changes to php.ini as
extension=php_pdo_sqlite.dll
extension=php_sqlsrv.dll
extension=php_sqlsrv_54_ts.dll
extension=php_pdo_sqlsrv_54_ts.dll
Similarly,this is my database configuration
$db['default']['hostname'] = "127.0.0.1";
$db['default']['port'] = 1433;
$db['default']['username'] = 'sa';
$db['default']['password'] = '**';
$db['default']['database'] = 'db_test';
$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;
But I keep on getting error as Fatal error:
Call to undefined function sqlsrv_connect() in
C:\xampp\htdocs\test\system\database\drivers\sqlsrv\sqlsrv_driver.php on line 76.
Could anyone please helpme with this?

Related

When am running a codeigniter project in local host, it shows error

The problem is am running this project in MAMP php version 8.0.3, and the codeIgniter version is 3, I think it will not support in php version 8.0.3. What is the solution of this problem?
This is my localhost url :http://localhost:8888/mansions/
$db['default']['hostname'] = 'localhost:8888';
$db['default']['username'] = 'root';
$db['default']['password'] = 'root';
$db['default']['database'] = 'mansions_new_live';
$db['default']['dbdriver'] = 'mysqli';
$db['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;
This is the database configuration details. Is there any solution for this?
I want to run this project in mamp server, its already working in windows server. but it is not working in mamp php version 8.0.3
Your mysql driver is deprecated. To use mysqli driver, add this parameter to your config file located in config/database.php.
$db['default']['dbdriver'] = 'mysqli';

Connect with remote mySql from localhost with codeigniter

I have a remote mysql server. Now I am developing a software in Codeigniter integrated with that mysql server. I gave the GRANT ALL to 'user'#'myid' in mysql user. But codeigniter shows the following error:
A Database Error Occurred
Unable to connect to your database server using the provided settings.
How can i use remote mysql in my local development environment?
BTW: I use WAMP in windown 7.
Thanks in advance.
EDIT:
Database Configuration:
$db['default']['hostname'] = '198.xxx.xx.66';
$db['default']['username'] = 'root';
$db['default']['password'] = 'xxxxxx';
$db['default']['database'] = 'm000db';
$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'] = TRUE;
$db['default']['stricton'] = FALSE;

Connect to SQL SERVER

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;

Connect to IBM DB2 from Codeigniter

I have never worked with DB2 before. I am trying to connect from codeigniter. I have used the following settings in my database config file:
$db['default']['hostname'] = 'ipAddress';
$db['default']['port'] = 'portNumber';
$db['default']['username'] = 'uname';
$db['default']['password'] = 'pword';
$db['default']['database'] = 'myDBName';
//$db['default']['dbdriver'] = 'pdo';
$db['default']['dbdriver'] = 'odbc';
$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;
and it throws the following error:
Unable to connect to your database server using the provided settings.
Filename: C:\xampp\htdocs\archive\system\database\DB_driver.php
Again, I am totally new to DB2, so in case I need to install anything extra (I assume the driver is already included in my latest CI download) or I need to define a dsn (please let me know how to do that if i require that) please do let me know, will very much appreciate your help.
Yes, you need to install the IBM Data Server Client package, or at least Runtime Client. Download the appropriate driver from http://www-01.ibm.com/support/docview.wss?uid=swg27016878
The manual explains how to configure DB2 access from a PHP application.
You need to add the full connection to the hostname parameter , as the following code
$active_group = 'default';
$active_record = FALSE;
$db['default']['hostname'] = "driver={IBM db2 odbc DRIVER};Database=DBNAME;hostname=localhost;port=50000;protocol=TCPIP;" . "uid=username; pwd=password";
$db['default']['username'] = 'username';
$db['default']['password'] = 'password';
$db['default']['database'] = 'DBNAME.SCHEMANAME';
$db['default']['dbdriver'] = 'odbc';
$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;

CodeIgniter issue with database

I am following a beginner's tutorial for CodeIgniter, but I can't get the view to load correctly because I have a database connection error. I have followed everything step-by-step, and gone through it again several times, but not been able to fix it. Could someone please help me, or at least explain why this is happening?
Here is the database configuration I currently have setup:
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = 'root';
$db['default']['database'] = 'helloworld';
$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'] = TRUE;
$db['default']['stricton'] = FALSE;
I've also autoloaded the database library with the following code:
$autoload['libraries'] = array('database');
I would also like to point out that I am using PHP version 5.3.13. I not sure if the version of PHP would affect my code, so I added it anyway.
The exact error I'm getting is:
A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: C:\wamp\www\CI\system\database\DB_driver.php
Line Number: 124
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root'; // default username if has not been set in phpmyadmin
$db['default']['password'] = ''; //leave it blank if has not been set in phpmyadmin
$db['default']['database'] = 'helloworld'; // this is your database name
$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'] = TRUE;
$db['default']['stricton'] = FALSE;
you might have tried to import the project to work space.Instead try to traverse to the project folder through project explorer

Categories