I am trying to connect to odbc database via php PDO class:
$dsn = 'odbc:CS_HDZipCodes32bit'; $username = 'demo'; $password = 'skdemo!'; $connection = new PDO($dsn, $username, $password); die( var_dump( $connection ) );
but when I do this, I get an error:
Fatal error: throw a "PDOException" exception with the message "driver could not be found" in C: \ inetpub \ wwwroot \ pdoClass.php: 7 Stack trace: # 0 C: \ inetpub \ wwwroot \ pdoClass.php (7): PDO β __ construct ('odbc: CS_HDZipCo ...', 'demo', 'skdemo!') # 1 {main} is thrown at C: \ inetpub \ wwwroot \ pdoClass.php on line 7
The value of $dsn is the name of the DSN created in my ODBC manager.

I know this particular DSN works because I managed to create another demo file and successfully connect via odbc_connect :
$connection = odbc_connect("CS_HDZipCodes32bit", 'demo', 'skdemo!'); if(!$connection){ die('connection failed'); } $statement = "SELECT * FROM ZipCodes"; $result = odbc_exec($connection, $statement);
I searched the PDO-ODBC documentation, as well as other resources on the Internet, but I cannot understand why PHP could not find the driver when trying to execute PDO.
Any ideas?
Update
I opened the phpinfo page to make sure the odbc driver is installed on a Marc B comment:

It looks like the driver is installed if it is not another driver.
Another update
When further checking my additional comment on phpini for Marc B, it looks like I don't have the ODBC POD driver installed:

So, if I had the ODBC driver for pdo installed, odbc would be at the end of the list, fix it?
php pdo odbc dsn
Chris schmitz
source share