title: Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect()
body: <p>I am trying to connect to a SQL Server that we can access through "Microsoft SQL Server Management Studio":</p>
  
  <p><a href="https://i.stack.imgur.com/3eAOB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3eAOB.png" alt="enter image description here"></a></p>
  
  <p>I've tried a bunch of different things I've seen on SO but nothing has worked. I get the error <code>Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect() in C:\Apache24\htdocs\test.php:52 Stack trace: #0 {main} thrown in C:\Apache24\htdocs\test.php on line 52</code> when running the following code on the <code>test.php</code> page:</p>
  
  <pre><code>$serverName = "SERVER.DOMAIN.COM, 1433"; //serverName\instanceName, portNumber (default is 1433)
  $connectionInfo = array( "Database"=&gt;"DB_NAME", "UID"=&gt;"USER", "PWD"=&gt;"PASS");
  $ma_conn = sqlsrv_connect( $serverName, $connectionInfo);
  
  if( $ma_conn ) {
       echo "Connection established.&lt;br /&gt;";
  }else{
       echo "Connection could not be established.&lt;br /&gt;";
       die( print_r( sqlsrv_errors(), true));
  }
  </code></pre>
  
  <p>My php.ini file has gone through many different extensions being enabled, but none have worked. I've tried all of the following:</p>
  
  <pre><code>extension = php_sqlsrv_56_ts.dll
  extension=php_sqlsrv_55_ts.dll
  extension=php_sqlsrv_55_nts.dll
  extension=php_sqlsrv_55_ts.dll
  extension=php_pdo_sqlsrv_55_ts.dll
  extension=php_pdo_mssql.dll
  extension=php_pdo_mysql.dll
  </code></pre>
  
  <p>Currently I have:</p>
  
  <pre><code>extension_dir = "c:\apache24\php7\ext\"
  extension=php_pdo.dll
  extension=php_pgsql.dll
  [PHP_SQLSRV]
  extension=php_sqlsrv_54_ts.dll
  [PHP_PDO_SQLSRV]
  extension=php_pdo_sqlsrv_54_ts.dll
  </code></pre>
  
  <p>On the machine with Apache and PHP in CMD I get the following:</p>
  
  <pre><code>Microsoft Windows [Version 6.3.9600]
  (c) 2013 Microsoft Corporation. All rights reserved.
  
  C:\Windows\system32&gt;php -c c:\apache24\php7\php.ini -v -display_startup_errors=1
  
  PHP Warning:  PHP Startup: Unable to load dynamic library 'c:\apache24\php7\ext\ php_pdo.dll' - %1 is not a valid Win32 application.
   in Unknown on line 0
  PHP Warning:  PHP Startup: Unable to load dynamic library 'c:\apache24\php7\ext\ php_sqlsrv_54_ts.dll' - %1 is not a valid Win32 application.
   in Unknown on line 0 PHP
  Warning:  PHP Startup: Unable to load dynamic library 'c:\apache24\php7\ext\ php_pdo_sqlsrv_54_ts.dll' - %1 is not a valid Win32 application.
   in Unknown on line 0
  PHP 7.0.10 (cli) (built: Aug 18 2016 09:48:53) ( ZTS )
  Copyright (c) 1997-2016 The PHP Group
  Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
  
  C:\Windows\system32&gt;
  </code></pre>
  
  <p>I've also downloaded and ran <code>SQLSRV32.EXE</code> inside of the <code>C:\Apache24\php7\ext</code> folder.</p>
  
  <p>I have:</p>
  
  <ul>
  <li>Windows Server 2012 RS win64</li>
  <li>Apache 2.4.23 win64</li>
  <li>PHP 7.0.10 win64</li>
  <li>Microsoft SQL Server 2012 Native Client win64</li>
  <li>Microsoft Visual C++ 2012 x64 &amp; x86 Redistributables (two different)</li>
  <li>Microsoft Visual C++ 2015 Redistributables (x64 &amp; x86) - 14.0.23026</li>
  <li>Microsoft ODBC Driver 11 for SQL Server</li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/qtIUd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qtIUd.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/oaQ4r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oaQ4r.png" alt="enter image description here"></a></p>