Home  >  Article  >  Backend Development  >  php连接access的mdb数据库出现问题,不知道是不是系统的问题

php连接access的mdb数据库出现问题,不知道是不是系统的问题

WBOY
WBOYOriginal
2016-06-23 14:14:311057browse

本帖最后由 helloword222 于 2013-06-26 12:32:21 编辑

$conn=new com("ADODB.Connection");
$conn->open("Driver={Microsoft Access Driver (*.mdb)};DBQ=".realpath("access/test.mdb"));
$rs=$conn->execute("select * from student");
echo $rs["name"];
?>
我将文件传到网站服务器上面,可以成功连接数据库并显示数据表的记录,说明代码没有问题。但是在本地windows7系统上测试的时候,出现如图所示的错误。

现在不知道问题是处在windows7系统的什么地方,请教了。

回复讨论(解决方案)

echo $conn;
看看是什么

一样的错误提示,就是在第三行:

$conn->open("Driver={Microsoft Access Driver (*.mdb)};DBQ=".realpath("access/test.mdb"));

查看了apache_error.log,是说我的系统不支持打开mdb数据库吗?

[Fri Jun 28 13:39:48.509954 2013] [:error] [pid 9916:tid 1504] [client 127.0.0.1:56207] PHP Fatal error:  Uncaught exception 'com_exception' with message 'Source: Microsoft OLE DB Provider for ODBC Drivers
Description: [Microsoft][ODBC \xc7\xfd\xb6\xaf\xb3\xcc\xd0\xf2\xb9\xdc\xc0\xed\xc6\xf7] \xce\xb4\xb7\xa2\xcf\xd6\xca\xfd\xbe\xdd\xd4\xb4\xc3\xfb\xb3\xc6\xb2\xa2\xc7\xd2\xce\xb4\xd6\xb8\xb6\xa8\xc4\xac\xc8\xcf\xc7\xfd\xb6\xaf\xb3\xcc\xd0\xf2' in C:\\wamp\\www\\php_mdb.php:3\nStack trace:\n#0 C:\\wamp\\www\\php_mdb.php(3): com->open('Driver={Microso...')\n#1 {main}\n  thrown in C:\\wamp\\www\\php_mdb.php on line 3

我的windows7是64位的,安装的WAMP也是64位的,现在换了32位的WAMP之后,终于解决问题了。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn