I installed the driver right in PHP, I added the extension in php.ini
, but when I try to connect with PDO in sqlserver, this error appears:
exception 'PDOException' with message 'SQLSTATE [08001]: [Microsoft] [ODBC Driver 11 for SQL Server] Named Pipes Provider: could not open a connection to SQL Server.
I do not know what it can be anymore, I'm using PHP version 5.5 and SQLserver express database 2014. Here is my database connection code:
$UserName = 'sa';
$Password = 'xxxxx';
try{
$con = new PDO("sqlsrv:Server=localhost;Database=banco", "$UserName", "$Password");
echo "banco conectado OK!";
}catch (PDOException $exception)
{
die("Não é possível se conectar ao banco de dados.<br />Error message:<br /><br />$exception.");
}
This is the first time I try to connect PHP with SQLserver. If anyone can help me, thank you:)