2
I installed the right driver in PHP, added the extension in php.ini
, but when I try to connect with PDO on sqlserver, this error appears:
Exception 'Pdoexception' with message 'SQLSTATE[08001]: [Microsoft][ODBC Driver 11 for SQL Server]Named Pipe Provider: could not open a connection to SQL Server.
I don’t know what else it might be, I’m using version 5.5 of PHP and the Sqlserver express 2014 database. Follow my connection code to the database:
$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.");
}
It’s the first time I try to connect PHP with Sqlserver. If anyone can help me, I appreciate :)
Which door to your SQLSERVER?
– durtto
the password xxxxx is purposeful?
– durtto
The door is the 1234... The password put 'xxxxx' only purposeful, just for the same question ;)
– Printf
try to put the door
– durtto
@stderr very well observed.
– durtto
the error continues?
– durtto
Opa, actually the variables were wrong, but even correcting, or even putting user and password direct, the error persists, already put the port tbm and nothing... :/
– Printf
the name of the bank is bank?
– durtto
Like the password, the name of the database was purposeful in the question... ;) this is the extension I added in php.ini... Extension=php_pdo_sqlsrv_55_ts.dll
– Printf