I am using php 7 and trying to connect to mssql server. I have this code:

$serverName = "server"; //serverName\instanceName
$connectionInfo = array( "Database"=>"database", "UID"=>"userid", "PWD"=>"password");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

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

but when I open the page, I get this error

Call to undefined function SQLSRV_CONNECT()

Is it an issue with the php version or simply an additional package that I should add to my Joomla install?


3 Answers 3


As @Sharky said, it seems like your SQLSRV extension isn't enabled. You can manually activate it by changing your php.ini file, enabling this extension and downloading the drivers.

PHP Documentation says:

The SQLSRV extension is enabled by adding appropriate DLL file to your PHP extension directory and the corresponding entry to the php.ini file. The SQLSRV download comes 8 driver files, four of which are for PDO support.

You can download the file here



Once you have downloaded the file, you have to execute it. A box will prompt asking where you want to extract.

You can extract to wherever you want to and then copy to your php extension folder or you can directly extract to your PHP extension folder. Usually your extension folder lies in: your-php-folder\bin\php\your-php-version or your-php-folder\bin\php and it's called ext. So the final path is something like this: your-php-folder\bin\php\ext.

To enable the dll in your php.ini file, you have to open it, and search for Extensions then add the dll like this:




If that doesn't work, you can try simply extension=sqlsrv_81_s leaving out php_ and .dll

  • I add the downloaded files to my extensions directory. What do I modify my php.ini file to? I'm not clear on what I need to add to that Jul 3, 2020 at 18:24
  • I updated my answer. Jul 3, 2020 at 18:34

Your issue is not related to Joomla. You are manually calling a function which does not exist on your PHP installation. This most likely means the required SQLSRV PHP extension is not enabled.

  • once I SSH into the box, what command do i run to enable this function? Jul 2, 2020 at 16:49

If you Joomla work and need to access the database use Joomla functional to connect database

$db = JFactory::getDbo();
  • 1
    Hello Dmitry, in this case he's trying to connect to the database using MSSQL. So he has to set up an environment first before start using MSSQL Server. But it seems like he managed to solve his problem. Jul 8, 2020 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.