How to connect PHP with SQLServer via PDO

3

I'm using the following code:

try {

    $con = new PDO("sqlsrv:Server=172.20.21.193,9090;Database=sgt","deb","123123");

    $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);  

} catch (PDOException $e) {
    die ("Erro na conexao com o banco de dados: ".$e->getMessage());
}

but is giving error while trying to connect. The PDO driver is installed. What other library or driver should I install, for my application to access the database? The PHP version is 5.6.9 (Linux Debian 8.1) and SQLServer is 2008 (access will be remote).

    
asked by anonymous 07.07.2015 / 19:31

1 answer

3

I was able to follow the link guidelines: link . The line of code looks like this: $con = new PDO("dblib:host=172.20.21.193,9090;dbname=sgt", "deb", "123123");

    
07.07.2015 / 22:33