gpt4 book ai didi

php - 未捕获的异常 'PDOException',消息为 'could not find driver'

转载 作者:可可西里 更新时间:2023-10-31 22:07:46 25 4
gpt4 key购买 nike

大家好我需要你的帮助

我遇到了错误

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));

?>

请帮忙..

最佳答案

根据您显示的phpinfo(),只安装了PDO Sqlite 驱动程序。您需要告知托管服务提供商安装 PDO MySQL 驱动程序。

关于php - 未捕获的异常 'PDOException',消息为 'could not find driver',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20950708/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com