Connect Sql Sever bank with PHP on windows 10

1

I am not able to connect to the SQL server database through PHP. I already downloaded the correct driver for the PHP version (php_pdo_sqlsrv_54_ts.dll) and moved it to the ext folder, set up php.ini to load the driver (extension = php_pdo_sqlsrv_54_ts.dll) and nothing. PHP simply does not recognize the driver.

I use PHP 5.4.6 (installed via easyPHP v12.1 32bit) on a Windows 10 machine. According to phpinfo () PHP is configured as Thread Safety.

The following code always results in an exception error:

try {
    $conn = new PDO("sqlsrv:server = tcp:ecardfid.database.windows.net,1433; Database = eCardFid", "eCardFid_DB", "##minha_senha##");
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e) {
    print("Error connecting to SQL Server.");
    die(print_r($e));
}

Error connecting to SQL Server.PDOException Object ( [message:protected] => could not find driver [string:Exception:private] => [code:protected] => 0 [file:protected] => C:\Program Files (x86)\EasyPHP-12.1\www\testetree.php [line:protected] => 6 [trace:Exception:private] => Array ( [0] => Array ( [file] => C:\Program Files (x86)\EasyPHP-12.1\www\testetree.php [line] => 6 [function] => __construct [class] => PDO [type] => -> [args] => Array ( [0] => sqlsrv:server = tcp:ecardfid.database.windows.net,1433; Database = eCardFid [1] => eCardFid_DB [2] => proddbazure@2017 ) ) ) [previous:Exception:private] => [errorInfo] => ) 1

Would anyone know to tell me what I'm doing wrong?

    
asked by anonymous 20.03.2017 / 17:19

1 answer

0

I do not know your version of SQL Server, in 2003 the DSN looked like this: dblib:[host];dbname=[nomedobanco];Auto Translate=False so I imagine it to be a problem in the same DSN. Anyway, before doing this it runs php_info() and see what comes out, it may be that it really is not loading the driver for some reason (restarted the server?).

    
20.03.2017 / 19:25