简体   繁体   English

致命错误:未捕获异常“PDOException”,消息“找不到驱动程序”

[英]Fatal error: Uncaught exception 'PDOException' with message 'could not find driver'

I'm new to web development and today, just as I was practicing with a local server (using XAMPP Apache and MySQL services), I got this error message:我是 Web 开发的新手,今天,就像我在本地服务器上练习(使用 XAMPP Apache 和 MySQL 服务)一样,我收到了以下错误消息:

 Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in C:\xampp\htdocs\blog\resources\query functions.php:3 Stack trace: #0 C:\xampp\htdocs\blog\resources\query functions.php(3): PDO->__construct('dblib:host=loca...', 'admin', 'root') #1 C:\xampp\htdocs\blog\resources\main.php(23): include('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\blog\resources\query functions.php on line 3

There's index.php file in C:\\xampp\\htdocs\\blog that includes main.php from C:\\xampp\\htdocs\\blog\\resources , then main.php includes another file in same directory called queryfunctions.php . C:\\xampp\\htdocs\\blog that includes main.php有 index.php 文件C:\\xampp\\htdocs\\blog that includes main.php来自C:\\xampp\\htdocs\\blog\\resources main.php ,然后 main.php 包含位于同一目录中的另一个名为queryfunctions.php文件。 main.php only has one line of code and that is to include queryfunctions.php . main.php 只有一行代码,即包含queryfunctions.php Then in that file I wrote this:然后在那个文件中我写了这个:

$database = new PDO('dblib:host=localhost;dbname=test;charset=UTF-8', "admin", "root");

And then it gives me the error whenever I go to test it.然后每当我去测试它时它都会给我错误。 I've read through a couple of questions and answers already, but none helped.我已经阅读了几个问题和答案,但没有一个帮助。 In my PHP info, these are the PDO drivers installed: mysql, odbc, sqlite, sqlite2 .在我的 PHP 信息中,这些是安装的 PDO 驱动程序: mysql, odbc, sqlite, sqlite2

PDO Driver for MySQL: Client API Version mysqlnd 5.0.8-dev - 20102224 - $Revision: 310735 $. MySQL 的 PDO 驱动程序:客户端 API 版本 mysqlnd 5.0.8-dev - 20102224 - $Revision: 310735 $。

If you are trying to connect to MySQL, use the MySQL connection string:如果您尝试连接到 MySQL,请使用 MySQL 连接字符串:

$database = new PDO('mysql:host=localhost;dbname=test', "admin", "root");

The dblib driver you are using is for Microsoft SQL and Sybase.您使用的dblib驱动程序用于 Microsoft SQL 和 Sybase。 If you are using XAMPP, chances are you are using MySQL not Microsoft SQL.如果您使用的是 XAMPP,则您使用的是 MySQL 而不是 Microsoft SQL。 If you are using Microsoft SQL, you will need to download and install it: http://www.php.net/manual/en/ref.pdo-dblib.php如果您使用的是 Microsoft SQL,则需要下载并安装它: http : //www.php.net/manual/en/ref.pdo-dblib.php

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获的异常&#39;PDOException&#39;,消息&#39;找不到驱动程序&#39; - Uncaught exception 'PDOException' with message 'could not find driver' PHP 致命错误:未捕获的 PDOException:找不到驱动程序 - PHP Fatal error: Uncaught PDOException: could not find driver 消息“找不到驱动程序”的未捕获异常“ PDOException”(到Oracle DB) - Uncaught exception 'PDOException' with message 'could not find driver' (to an Oracle DB) 消息“找不到驱动程序”的异常“ PDOException” - exception 'PDOException' with message 'could not find driver' 未捕获的PDOException:找不到驱动程序 - Uncaught PDOException: could not find driver 使用Sqlite的消息“找不到驱动程序”的未捕获异常“ PDOException”:配置错误? - Uncaught exception 'PDOException' with message 'could not find driver' using Sqlite: mis-configuration? redbean php:致命错误:未捕获异常&#39;PDOException&#39;,消息&#39;无法连接到数据库 - redbean php: Fatal error: Uncaught exception 'PDOException' with message 'Could not connect to database 致命错误:未捕获的异常“PDOException” - Fatal Error: Uncaught exception 'PDOException' 加载的数据: <br /> 致命错误 :消息未捕获的异常“ PDOException” - Data Loaded: <br /> <b>Fatal error</b>: Uncaught exception 'PDOException' with message PHP致命错误:消息为&#39;SQLSTATE [42000]的未捕获异常&#39;PDOException&#39;: - PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM