Brent Connor
Brent Connor

Reputation: 628

sqlsrv connection string not valid [87]

Set up:

Already completed:

Additionally, I did have trouble with SQL Reporting Service taking port 80. This was giving me a problem with Apache, so I directed SQL Reporting Service to use port 8081.

<?php
$server = "computer_name\MSSQLSERVER";
$user = "sa";
$pass = "password";
$db = "pcm";
$connInfo = array("Database"=>$db, "UID"=>$user, "PWD"=>$pass);
$conn = sqlsrv_connect($server, $connInfo) or die( print_r( sqlsrv_errors(), true));
?>

Upvotes: 1

Views: 1401

Answers (1)

David Myers
David Myers

Reputation: 411

If you are using the PDO extension, you will have to use a PDO connection instead of the sqlsrv_connect() function. Microsoft doesn't support the UID or PWD keys that you are providing when trying to connect via the PDO extension. Try this instead:

$conn = new PDO('sqlsrv:Server = ' . $server . '; Database = ' . $db, $user, $pass);

http://php.net/manual/en/ref.pdo-sqlsrv.connection.php

Upvotes: 1

Related Questions