Home > Article > Backend Development > PHP5.2.3 connects to sqlserver2008, sqlserver2008_PHP tutorial
1, download the driver
Download address: https://www.microsoft.com/en-us/download/details.aspx?id=20098
What I downloaded is: SQLSRV20.EXE because my php version is 5.2.3. Please see the download instructions for the specific version.
2, decompress SQLSRV20.EXE,
3. Modify php.ini and add extension=php_sqlsrv_52_ts_vc6.dll
4, copy extension=php_sqlsrv_52_ts_vc6.dll
5, restart the server
$server = '(local)';
$user = 'sa';
$pass='sa';
$dbname='testdb';
if(sqlsrv_connect($server, array('UID' => $user ,'PWD'=> $pass, 'Database' => $dbname)))
{
echo "Success ";
}
else
{
echo "Failed";
}
?>