Creating a Connection
suggest change$dbServer = "localhost,1234"; //Name of the server/instance, including optional port number (default is 1433)
$dbName = "db001"; //Name of the database
$dbUser = "user"; //Name of the user
$dbPassword = "password"; //DB Password of that user
$connectionInfo = array(
"Database" => $dbName,
"UID" => $dbUser,
"PWD" => $dbPassword
);
$conn = sqlsrv_connect($dbServer, $connectionInfo);
SQLSRV also has a PDO Driver. To connect using PDO:
$conn = new PDO("sqlsrv:Server=localhost,1234;Database=db001", $dbUser, $dbPassword);
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents