Michael Lockwood
Michael Lockwood

Reputation: 23

PDOException - Connection Failed - Could not find driver - PHP5/SQLite/Ubuntu

I am having a baffling issue. I've correctly set up PHP5/SQLite before. However, this time it's not working.

The basic expectation of functionality is that I make a generic DB connection using:

$dblocation = "path/to/database.db";
$dbConn = new PDO("sqlite:" . $dblocation); 

From there I am getting the

Connection Failed: Could not find driver.

I have done the following to resolve this.

  1. Checked documentation with: php -a -c /etc/php5/cli/php.ini and phpinfo()

    sqlite3
    
    SQLite3 support => enabled
    SQLite3 module version => 0.7-dev
    SQLite Library => 3.8.2
    
  2. Checked available drivers:

    php > print_r(PDO::getAvailableDrivers());
    Array
    (
       [0] => mysql
       [1] => sqlite
    )
    php >
    
  3. Using Apache2, enabled the pdo and pdo_sqlite

    With that, I don't need to uncomment the extension line in the PHP.ini file. If I do uncomment it, I get the expected unable to unregister error that comes when you have two attempts to load.

  4. Removed all PHP PDO installs and reinstalled.

  5. Removed PHP itself and reinstalled.

None of these have helped.

Like I have said, I have been able to get this to function correctly before, so I am not sure what is wrong here. Hopefully, somebody has a more solid answer than what I can find. From what I am seeing everything appears to be configured correctly.

Any assistance anybody can provide would be very appreciated.

Upvotes: 0

Views: 666

Answers (1)

Mirage
Mirage

Reputation: 177

Keep in mind that PHP CLI uses a different ini than the one used by apache. Try to run an phpinfo(); via the webserver. This should tell you more info.

Upvotes: 1

Related Questions