简体   繁体   English

使用msaccess的PHP

[英]php using msaccess

Because no one answer my question Codeigniter using ms access database , i make new question i not using codeigniter 因为没有人使用ms Access数据库回答我的问题Codeigniter ,所以我提出了新的问题,我没有使用Codeigniter

if I using mdb from my computer it works but if i using mdb from another computer in my network 如果我从计算机上使用mdb可以正常工作,但是如果我从网络中的另一台计算机上使用mdb

i got error this is my CODE 我有错误,这是我的代码

<?php

$connect = odbc_connect("testdb", "", "");
$query = "SELECT * FROM ACGroup";
$result = odbc_exec($connect, $query);

while(odbc_fetch_row($result)){
  $name = odbc_result($result, 1);
  echo("$name");
}

?>

i make odbc where the data its from another computer in my network 我制作odbc,其中数据来自我网络中的另一台计算机

"testdb" are data sourcename and database \\ip\folder\testdb.mdb

and i got this error 我得到这个错误

   Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC Microsoft Access Driver] 
    The Microsoft Jet database engine cannot open the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view its data.,
     SQL state S1000 in SQLConnect in D:\blabla\coba.php on line 3

I already try folder setting but it not work 我已经尝试过文件夹设置,但是它不起作用

The ODBC connection string you are using ( "testdb" ) does not even specify a database driver, much less a database file. 您正在使用的ODBC连接字符串( "testdb" )甚至没有指定数据库驱动程序,更不用说数据库文件了。 You will need to read up on the appropriate format for $dsn . 您将需要阅读适用于$dsn的适当格式。 ( The php.net page even has a few examples for Access files.) php.net页面甚至还有一些访问文件的示例。)

The problem possibly lies in the permissions your Apache user has on the mdb file. 问题可能出在您的Apache用户对mdb文件的权限上。

Go to your mdb file, right-clik on the file -> Properties ->Security tab and see if your Apache user is on the User Groups that have access/control on the mdb file. 转到您的mdb文件,在文件->属性->安全选项卡上右击,然后查看您的Apache用户是否在对mdb文件具有访问/控制权限的用户组中。

In order to see/change your Apache user, go to Control Panel-> Administrative Tools -> Services, right-click on Apache service -> Properties -> Logon tab. 为了查看/更改您的Apache用户,请转到控制面板->管理工具->服务,右键单击Apache服务->属性->登录选项卡。 In the Log on as option, see if the user selected belongs to the User Groups that have access to mdb file. 在“登录身份”选项中,查看所选用户是否属于有权访问mdb文件的用户组。 If not, create one and add it to the User Groups and then use it as the Apache account. 如果不是,请创建一个并将其添加到用户组中,然后将其用作Apache帐户。

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

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