Uncaught Error: Call to undefined function sqlsrv_connect()

喜你入骨 提交于 2020-04-30 11:22:05

问题


I installed xampp-win32-7.2.11-0-VC15-installer.exe, downloaded and extracted SQLSRV53.EXE to C:\xampp\php\ext, added

;extension=php_sqlsrv_72_ts_x64.dll

;extension=php_pdo_sqlsrv_72_ts_x64.dll

to php.ini and still get Uncaught Error: Call to undefined function sqlsrv_connect()

my code:

<?php
        $serverName = "XXXXX\SQLEXPRESS"; //serverName\instanceName

        // Since UID and PWD are not specified in the $connectionInfo array,
        // The connection will be attempted using Windows Authentication.
        $connectionInfo = array( "Database"=>"XXXX");
        $conn = sqlsrv_connect( $serverName, $connectionInfo);

        if( $conn ) {
            echo "Connection established.<br />";
        }else{
            echo "Connection could not be established.<br />";
            die( print_r( sqlsrv_errors(), true));
        }
    ?>

回答1:


1) php_sqlsrv_72_ts_x64 AND php_pdo_sqlsrv_72_ts_x64 should be 32 bit same as xampp

2) Also compatible with PHP version




回答2:


In my case there were 2 php.ini files on wamp server. one of them is located at C:\wamp\bin\apache\Apachex.x.x\bin folder and when i tried to connect through sqlsrv_connect function, we are referring to the php.ini file in the apache folder.

So please check the php.ini in apache folder and enable the extension and test your connection with sqlsrv_connect.

Hope this will help.



来源:https://stackoverflow.com/questions/53041809/uncaught-error-call-to-undefined-function-sqlsrv-connect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!