简体   繁体   English

使用PHP连接到MS Access数据库

[英]Connecting to ms access database using php

Am getting could not find file error while connecting to ms access database using php. 我正在使用php连接到ms Access数据库时找不到文件错误。

and my code is 我的代码是

$dbName = $_SERVER["DOCUMENT_ROOT"] . "msdb\jcdbone.mdb";
if (!file_exists($dbName)) {
    die("Could not find database file.");
}
$db = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$dbName; Uid=; Pwd=;");

How to connect to ms access database using php? 如何使用PHP连接到MS Access数据库? help me with small example. 帮我举个小例子。 ....Thanks in advance ....提前致谢

If you're getting an could not find file error then that means your path is probably wrong. 如果您遇到找不到文件的错误,则说明您的路径可能有误。

Try adding 尝试添加

echo $dbName;

right below 就在下面

$dbName = $_SERVER["DOCUMENT_ROOT"] . "msdb\jcdbone.mdb";

and then compare that path to the actual location of your jcdbone.mdb file and then adjust accordingly. 然后将该路径与jcdbone.mdb文件的实际位置进行比较,然后进行相应调整。

A quick Google shows you probably picked this example up from a sitepoint article. 快速的Google展示您可能是从站点点文章中挑选了此示例的。 The code sample should be good -- you just need to make sure the path is correct. 代码示例应该很好-您只需要确保路径正确即可。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM