Call to undefined function sqlsrv_connect() - Troubleshooting

我与影子孤独终老i 提交于 2019-12-01 23:52:09

You have added the PDO variant of SQLSRV drivers to the extension list, but have not added the base drivers php_sqlsrv_55_ts.dll.

Add to the php.ini:

extension=php_sqlsrv_55_ts.dll

or

extension=php_sqlsrv_55_nts.dll

Also, you really should be using either the Thread-Safe (_ts.dll) or Non-Thread-Safe (_nts.dll) versions of the driver, not both. I believe that, as you are using an Apache Server, you should be using the Thread-Safe versions. So you php.ini should have:

extension=php_sqlsrv_55_ts.dll
extension=php_pdo_sqlsrv_55_ts.dll

You probably edited the wrong php.ini file. Check the right php.ini file with php info.

You can use this script:

<?php echo phpinfo(); ?>

Or if you have CLI access type php -i to get the info listed. Check for the right path of your php.ini file.

Try below code to connect mssql database

$server = 'dburl.com\MSSQLSERVER, 1433';
$username = 'uname';
$password = 'password';

$connectionInfo = array( "Database"=>$database, "UID"=>$username, "PWD"=>$password,"ReturnDatesAsStrings"=>true);
$conn = sqlsrv_connect( $server, $connectionInfo);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!