Skip to content

Instantly share code, notes, and snippets.

@Mauryashubham
Created August 19, 2017 09:25
Show Gist options
  • Save Mauryashubham/444d05e2f74db3f68500966389e37106 to your computer and use it in GitHub Desktop.
Save Mauryashubham/444d05e2f74db3f68500966389e37106 to your computer and use it in GitHub Desktop.
Connect PHP to MSSQL database
/**
@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