找不到数据源名称,并且未指定默认驱动程序xxx

时间:2018-08-30 22:36:00

标签: php linux ms-access odbc

我试图通过基于Linux的虚拟主机连接到MS Access数据库(test.mdb),但出现错误消息:

PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[IM002] SQLDriverConnect: 0 [unixODBC][Driver Manager]Data source name not found, and no default driver specified' in /test.php:10
Stack trace:
#0 /test.php(10): PDO->__construct('odbc:DRIVER={Mi...')
#1 {main}
  thrown in /test.php on line 10

我的测试PHP代码如下:

<?php

$dbName = $_SERVER["DOCUMENT_ROOT"] . "/test.mdb";

if (!file_exists($dbName)) {
    die("Could not find database file.");
}


$db = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$dbName; Uid=; Pwd=;");

?>

我的PHP信息(v5.5.38)显示:

PDO > PDO drivers = mysql, odbc, sqlite
PDO_ODBC > ODBC Connection Pooling = Enabled, strict matching

0 个答案:

没有答案