What this error is in PHP with SQL Server

1

Hello!

After a long wait at the end, I have to develop a system using Yii2 and SQL Server .

I downloaded XAMPP with PHP 5.6.31 and I installed SQL Server 2008 and I can not connect to the database.

I have already tried downloading the official versions of SQL Server drivers for Microsoft PHP using this link:

Microsoft Drivers for PHP for SQL Server

I have also activated the extensions in the file php.ini

extension=php_pdo_sqlsrv_56_nts.dll extension=php_pdo_sqlsrv_56_ts.dll extension=php_sqlsrv_56_ts.dll extension=php_sqlsrv_56_nts.dll

My configuration file to the database is as follows:

return [
'class' => 'yii\db\Connection',
'dsn' => 'sqlsrv:Server=127.0.0.1;Database=softwareoperacional',
'username' => 'sa',
'password' => 'admin123',
'charset' => 'utf8',
];

As an error message I get the following:

exception 'PDOException' with message 'SQLSTATE [08001]: [Microsoft] [ODBC Driver 11 for SQL Server] Named Pipes Provider: Could not open a connection to SQL Server

Check the PHPInfo and show the following in the PDO Drivers

I connect to my database manager as follows

Does anyone here would be kind enough to tell me what I'm doing wrong in the configuration or what version should I install?

Beforehand, thank you for your attention, if there is something that I need, I gladly review it, I remain pending.

Greetings,

    
asked by Sebastian Salazar 01.03.2018 в 15:04
source

2 answers

1
  • Download the ODBC driver for SQL Server.
  • Enable extensions extension = php_pdo_sqlsrv_56_nts.dll and extension = php_sqlsrv_56_nts.dll in PHP.ini.
  • Add the extensions that were enabled in the path xampp \ php \ ext.
  • Restart XAMPP.
  • Change the connection string 'sqlsrv: Server = 127.0.0.1; Database = operative software' and place this 'sqlsrv: Server = SEBASTIAN-PC \ SQLEXPRESS; Database = operative software'.
  • answered by 02.03.2018 / 17:22
    source
    0

    Apparently you do not have the corresponding driver installed yet, I'll leave you the microsoft documentation about it.

    Click here

    On the other hand, in the configuration of PHP ini you must add extension = php_pdo_sqlsrv_XX_ts.dll as appropriate.

        
    answered by 01.03.2018 в 16:31