Created
August 19, 2017 09:25
-
-
Save Mauryashubham/444d05e2f74db3f68500966389e37106 to your computer and use it in GitHub Desktop.
Connect PHP to MSSQL database
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
/** | |
@author : Shubham Maurya, | |
Email id : [email protected] | |
**/ | |
Hi all , Welcome to shubhammaurya.com , Today we are going to discuss , | |
How to Call Connect PHP to MSSQL database | |
1.Make a file in notepad and save it as dbconfig.php and paste the below code. | |
<?php | |
$server_name = "Your server name"; | |
$database_name = "Your database name"; | |
$DB_user = "Your Username"; | |
$DB_pass = "Your Password"; | |
try | |
{ | |
$conn = new PDO("sqlsrv:Server=$server_name;Database=$database_name;ConnectionPooling=0",$DB_user, $DB_pass); | |
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
echo "done"; | |
} | |
catch(PDOException $e) | |
{ | |
$e->getMessage(); | |
} | |
?> | |
STAY CONNECTED FOR MORE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment