1

I'm having an error connecting to my database on another server since PHP.

Install the extension to connect, in my phpinfo() I can see it.

enter image description here

In my php code I execute the following:

if( sqlsrv_configure("WarningsReturnAsErrors", 0) === false)  
{  
    DisplayErrors();  
    die;  
}  else {
    echo sqlsrv_configure("WarningsReturnAsErrors", 0);
}

And what returns is a "1"

However, if I run:

$serverName = "MY.IP,1433";
$database = "my_database";
$uid = 'usr';
$pwd = '12345';
try {
    $conn = new PDO(
        "sqlsrv:server=$serverName;Database=$database",
        $uid,
        $pwd,
        array(
            //PDO::ATTR_PERSISTENT => true,
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
        )
    );
}
catch(PDOException $e) {
    die("Error connecting to SQL Server: " . $e->getMessage());
}

I receive the error

could not find driver

sioesi
  • 497
  • 1
  • 5
  • 20
  • https://stackoverflow.com/questions/2852748/pdoexception-could-not-find-driver – Bolli Jun 27 '18 at 00:46
  • 1
    did you install the driver ? https://learn.microsoft.com/en-us/sql/connect/php/example-application-pdo-sqlsrv-driver?view=sql-server-2017 – Bolli Jun 27 '18 at 00:48
  • You have installed php_sqlsrv_.dll extension, but you need php_pdo_sqlsrv_.dll. – Zhorov Jun 27 '18 at 05:43

0 Answers0