Loading...

Knowledge Base
Categories: ,

Connect to MSSQL via PHP

Share

<?php
//Code for connection on Arvixe
$myServer = "localhost\SQLEXPRESS";
$myUser = "Database User Name"; // replace with your values
$myPass = "Database Password"; // replace with your values
$myDB = "Database Name"; // replace with your values

//create an instance of the  ADO connection object
$conn = new COM ("ADODB.Connection")
  or die("Cannot start ADO");

//define connection string, specify database driver
 $connStr = "PROVIDER=SQLOLEDB;SERVER=".$myServer.";UID=".$myUser.";PWD=".$myPass.";DATABASE=".$myDB;
  $conn->open($connStr); //Open the connection to the database
?>

Did you find this article helpful?

 
* Your feedback is too short

Loading...