The Disconnect Between pdo_sqlsrv and PHP Configuration
The error message "could not find driver" when attempting to connect via PDO is a classic symptom of a configuration mismatch, but the root cause is often misunderstood by developers working with legacy environments like PHP 5.3.8. In your specific scenario, you have successfully loaded the extension without triggering an Apache startup error, yet phpinfo() shows blank fields for pdo_sqlsrv except for log_severity. This indicates that the DLL file is physically present and recognized by the PHP runtime loader, but the underlying driver library required to establish the database connection remains missing or unlinked.
The issue stems from a fundamental misunderstanding of how the Microsoft SQL Server driver architecture works. When you download the "Microsoft ODBC Driver for SQL Server" (version 2.0 or 3.0), you are installing an ODBC driver stack, not the native PDO driver directly. The php_pdo_sqlsrv_53_ts_vc9.dll file acts as a wrapper that translates PDO calls into ODBC calls. If this wrapper cannot find the underlying Microsoft ODBC Driver installed on the system, it fails to initialize the connection pool and throws the "could not find driver" error.
To resolve this, you must ensure the native ODBC driver is registered in the Windows registry before PHP attempts to use it. Simply downloading the driver from Microsoft does not automatically register the necessary components for the php_pdo_sqlsrv extension to function. You need to run the installer for the "Microsoft ODBC Driver for SQL Server" (specifically version 13 or higher is recommended, though older versions can work) and ensure it completes a successful installation. After installing the driver, you must restart your Apache service to clear any cached library paths.
Once the native driver is registered, the php_pdo_sqlsrv extension should be able to locate its dependencies. However, there is a critical detail regarding the connection string in your code:
$DBH = new PDO("mssql:host=xxxx;dbname=xxxx", 'xxxx', 'xxxx');
The DSN format you are using (mssql:...) corresponds to the legacy SQL Server Native Client or the older sqlsrv driver, not the standard ODBC-based pdo_sqlsrv. When using the pdo_sqlsrv extension with the modern Microsoft ODBC Driver stack, the connection string must explicitly specify the driver class and parameters. The correct syntax for the ODBC-based PDO connection looks like this:
$DBH = new PDO(
"sqlsrv:Server=xxxx;Database=xxxx",
'xxxx',
'xxxx',
[
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
]
);
Using the mssql: prefix with the modern ODBC driver stack will inevitably result in connection failures because that namespace is reserved for different underlying libraries. If you continue to experience issues despite having the correct DLLs and drivers, check the Windows Event Viewer under "Application" logs for specific errors regarding the ODBC Driver installation. Often, the driver fails silently during installation if a previous version is left behind or if the Service Pack 2 (for SQL Server 2008 R2) requirements are not met.
For modern PHP environments, relying on php_pdo_sqlsrv_53_ts_vc9.dll is no longer advisable due to security vulnerabilities and lack of support for newer SQL Server versions. If you have the flexibility to upgrade your stack, moving to a supported version of PHP (7.x or 8.x) and using the pdo_sqlsrv extension compatible with the Microsoft ODBC Driver 17 or 18 provides significantly better stability and performance. This transition eliminates the ambiguity between ODBC wrappers and native drivers, as the newer extensions often include the necessary driver logic internally or bundle them more tightly.
If you are constrained to PHP 5.3.8 for legacy compatibility reasons, ensure that the php_pdo_sqlsrv extension you have installed matches the exact architecture of your XAMPP installation (Thread Safe vs Non-Thread Safe). Mismatched architectures are a common cause for the "blank fields" seen in phpinfo(). Finally, verify that the SQLSRV environment variables are set correctly in your system PATH, as the extension searches these locations to locate the native driver DLLs.