Search code examples
phpsql-serverxamppsqlsrv

Uncaught Error: Call to undefined function sqlsrv_connect()


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));
        }
    ?>

Solution

    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