System Information
CMS: Wordpress
Web Server: XAMPP
PHP Version: 5.5.30
MS Management Studio 17
Goal
Establish MSSQL Database connection using PHP
What has been done
- Downloaded SQLSRV Drivers
- Copied files php_pdo_sqlsrv_55_nts.dll and php_pdo_sqlsrv_55_ts.dll to the directory
C:xamppphpext
- Added the following lines to the dynamic extensions part in the php.ini file:
extension=php_pdo_sqlsrv_55_ts.dll
andextension=php_pdo_sqlsrv_55_nts.dll
- Restarted Web Server
- Confirmed sqlsrv is listed in phpinfo()
Code
$serverName = "technology-pcsqlexpress";
// The connection will be attempted using Windows Authentication.
$connectionInfo = array( "Database"=>"example_db");
$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));
}
Error
See Question&Answers more detail:osCall to undefined function sqlsrv_connect()