2014-01-06 204 views
11

大家好,我需要你的幫助未捕獲的異常「PDOException」有消息「找不到驅動程序」

我有錯誤

Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in /home/rails/public_html/newidenty/server.php:12 Stack trace: 
#0 /home/rails/public_html/newidenty/server.php(12): PDO->__construct('mysql:dbname=ra...', 'rails_identy', 'rails_identy') 
#1 /home/rails/public_html/newidenty/registration.php(2): include('/home/rails/pub...') 
#2 {main} thrown in /home/rails/public_html/newidenty/server.php on line 12. 

我使用118.139.182.107/~rails/HTML/test。 php擁有所有PHP版本 的信息,並顯示PDO庫。

我的託管提供說,他們在其中安裝PDO,但得到的問題

我的代碼是

<?php 
    $dsn  = 'mysql:dbname=*****;host=localhost'; 
    $username = '*****'; 
    $password = '*****'; 

    // error reporting (this is a demo, after all!) 
    ini_set('display_errors',1);error_reporting(E_ALL); 

    // Autoloading (composer is preferred, but for this example let's just do this) 
    require_once('oauth2-server-php/src/OAuth2/Autoloader.php'); 
    OAuth2\Autoloader::register(); 
    $PDO = new PDO("mysql:dbname=*****;host=localhost",$username,$password); 
    // $dsn is the Data Source Name for your database, for exmaple "mysql:dbname=my_oauth2_db;host=localhost" 
    $storage = new OAuth2\Storage\Pdo(array('dsn' => $dsn, 'username' => $username, 'password' => $password)); 

    // Pass a storage object or array of storage objects to the OAuth2 server class 
    $server = new OAuth2\Server($storage); 

    // Add the "Client Credentials" grant type (it is the simplest of the grant types) 
    $server->addGrantType(new OAuth2\GrantType\ClientCredentials($storage)); 

    // Add the "Authorization Code" grant type (this is where the oauth magic happens) 
    $server->addGrantType(new OAuth2\GrantType\AuthorizationCode($storage)); 

?> 

請幫助..

+0

@Flosculus你可以解釋一下我不知道這是$ dsn –

+0

對不起,我刪除了我的評論,因爲它是錯的。 – Flosculus

+0

我認爲這個錯誤意味着他們安裝了PDO,但不是它的MySQL驅動程序。 – Barmar

回答

25

按照phpinfo()你顯示,只有PDO SQLite的驅動程序已安裝。您需要告訴託管服務提供商安裝PDO MySQL驅動程序。

+0

@Barrmar你是對的:-)謝謝你的幫助 –

+0

誰給了我一個無聲的倒退,爲什麼? – Barmar

+0

我不知道。爲什麼? –

相關問題