No it's not a Duplicate. In that also they said to include dll files. I did it but still I got same error
I need to connect sql server to codeigniter project. And I added
extension = php_sqlsrv_56_ts.dll in php.ini
But still I got fatal Error.
$db['default'] = array(
'dsn' => '',
'hostname' => 'ADMIN-PC\SQLEXPRESS',
'username' => 'name',
'password' => 'password',
'database' => 'dbname',
'dbdriver' => 'sqlsrv',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
This is what I got while run this on localhost (Appache Server)
Fatal error: Call to undefined function sqlsrv_connect() in C:\xampp\htdocs\MyProject\system\database\drivers\sqlsrv\sqlsrv_driver.php on line 144
A PHP Error was encountered Severity: Error
Message: Call to undefined function sqlsrv_connect()
Filename: sqlsrv/sqlsrv_driver.php
Line Number: 144
Backtrace:
After many attempts I finally find solution.
All you need to follow below steps.
Step 1: Find version of your php by using php_info().
Step 2 : You have to find exact sqlsrv compiler (which means the .dll file) for your php version.
Eg : if you are using php 7.1 then the exact compiler is php_sqlsrv_71_ts.dll
like if you using php 5.6 then it should be php_sqlsrv_56_ts.dll
Step 3 : Add this in your xampp/php/ext folder
Step 4 : Then add this line in your php.ini file extension=php_sqlsrv_71_ts_.dll
Step 5 : Now stop and start Apache server.
Now You can find sqlsrv in php_info().
if you didn't find then you should check error log.
That's all Thank you folks :)