Created
September 25, 2018 13:09
-
-
Save nzuwera/337abfd10f6e5da102bc3f4ddac47fc2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
How to install and configure PHP to connect MSSQL on windows | |
Step 1: Download Microsoft ODBC related to Xampp or Wamp : https://www.microsoft.com/en-us/download/details.aspx?id=50420 | |
Step 2: Download Microsoft SQL Driver for PHP related to your PHP version : https://docs.microsoft.com/en-us/sql/connect/php/sqlsrv-driver-api-reference?view=sql-server-2017 | |
Step 3: Add the extracted dll file in php extentsion directory | |
Step 4: update php.ini to load the new extensions | |
Step 5: Restart Apache server | |
Step 6: Test connection below script. just remember to use the correct credentials for your database | |
*/ | |
<?php | |
$server="DESKTOP-ODLPHLJ\\SQLEXPRESS"; | |
$options = array("UID" => "<DB_USERNAME>","PWD" =>"<DB_PASSWORD>","Database"=>"<DATABASE_NAME>"); | |
$conn = sqlsrv_connect($server,$options); | |
if ($conn === false) die("<pre>".print_r(sqlsrv_errors(), true)); | |
echo "Successfully connected!"; | |
sqlsrv_close($conn); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment