PDO Exception "Could not find driver" (pgsql)

18,462

Solution 1

In Wamp (windows)...

copy C:\wamp\bin\php\php5.x.xx\libpq.dll

paste in C:\Windows\System32\

Solution 2

on Wamp, there are 2 php.ini files, you will have to check if the Postgresql extension is on both! The extension line is

extension=php_pdo_pgsql.dll

So check on

C:\wamp\bin\apache\apache2.4.9\bin\php.ini

Also check on

C:\wamp\apache\apache2.4.9\bin\php.ini

After adding the extension line, restart Apache and it will work.

Share:
18,462
Roy
Author by

Roy

I'm a Web Developer with the US Fish and Wildlife Service in Atlanta, GA.

Updated on June 13, 2022

Comments

  • Roy
    Roy almost 2 years

    I downloaded and installed PostgreSQL 9.2.3, which came with Stackbuilder.

    I used the PostgreSQL Stackbuilder to install Apache (2.2.22) & PHP (5.4.5).

    Now I'm trying to connect to a database with PDO, but I'm getting a driver not found error.

    I've un-commented the extension=php_pgsql.dll & extension=php_pdo_pgsql.dll in my php.ini file.

    My phpinfo(); function shows that they're enabled. enter image description here

    The main thing I'm noticing is that within my php\ directory there's no ext\ directory with these files. I would have assumed that these files would have been automatically installed to a php\ subdirectory.

    Where could these extensions be stored; do I need to designate an absolute path for php to find them?

    UPDATE: So I went into php.ini and turned on Startup Errors. When I launch the commandline php.exe I get errors stating that php_pgsql.dll & php_pdo_pgsql.dll can't be found.

    enter image description here It looks like they're trying to reference them on a D: drive, which I don't have. I installed everything to the same directory on the E: drive. I can't find the extensions anywhere (and neither can php).

  • eddie_cat
    eddie_cat over 9 years
    Please add some explanation for this.