Home >Backend Development >PHP Tutorial >php5.2.3 connects to sqlserver2008
1, Download 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, Unzip 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 "Failure";
}
?>
The above introduces how to connect php5.2.3 to sqlserver2008, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.