[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 593
  • Last Modified:

PHP to MS Access odbc connection error

Hi there,

I have been looking for a solution to my problem of which I have found a few threads here and elsewhere regarding the DSN connection problem when attempting to connect php to an access database residing on a netwrok drive.

It works perfectly when the database is stored locally but not when I am trying to contact the main database on the share. Tried the DSN less approach too but to no avail. I assume it might be permissions but some help would be much appreciated.

THank you
0
databarracks
Asked:
databarracks
  • 10
  • 4
1 Solution
 
TonyRebaCommented:
Make sure you can connect and have access to the database in the hosting computer .
0
 
databarracksAuthor Commented:
I do have full read/write permissions to the Access Database and everything else within that drive? I make regular changes in the backend database?
0
 
databarracksAuthor Commented:
Are there other permission I might require perhaps?
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
TonyRebaCommented:
what is the php error you are getting?
0
 
databarracksAuthor Commented:
( ! ) Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC Microsoft Access Driver] The Microsoft Access database engine cannot open or write to the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view and write its data., SQL state S1000 in SQLConnect in C:\wamp\www\test\ds_system.php on line 5
0
 
databarracksAuthor Commented:
Nobody else has this file open and no laccdb files exist.
0
 
TonyRebaCommented:
Try something like:

$db = ADONewConnection('access');
$dsn =
  "Driver={Microsoft Access Driver (*.mdb)};Dbq=d:\inetpub\adodb\northwind.mdb;Uid=Admin;Pwd=;";
$db->Connect($dsn);

0
 
databarracksAuthor Commented:
Ok I tried that and go this error:

( ! ) Fatal error: Call to undefined function ADONewConnection() in C:\wamp\www\test\ds_system.php on line 5

Line 5 being $db = ADONewConnection('access');
0
 
TonyRebaCommented:
Make sure you have  access to the share drive folder where the  *.accdb or mdb file physically resides. (read, write access to the folder) for the System account that is configured

And Restart

0
 
databarracksAuthor Commented:
Yes I do, still no luck
0
 
databarracksAuthor Commented:
Hi there do you have any further suggestions?
0
 
databarracksAuthor Commented:
How can make Apache-Service run with a Domain (network)-User, as this might be the issue perhaps?
0
 
NoiSCommented:
I guess that your trouble is that the Apache runs under a user wich don't have permissions to open a file on the network.
One solution is to share the directory with permissions to "everyone" and map this dir on computer where Apache is running, so you can try read it like a local file.
Another is to use PHP_FPM (http://php-fpm.org/) to run some scripts under another user to avoid problems of network permissions.

0
 
databarracksAuthor Commented:
Hi there, I think you have nailed it there. I have done this and it seems to be working just fine. Many thanks for your response you have been most helpful.
0
 
databarracksAuthor Commented:
Very good advice
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 10
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now