I have an access database which I would like to CRUD with PDO. When My database is stored on C:\wamp\www\test.accdb
I can connect. However, the database I am interested in is stored on our office server, at \server1abc123test.accdb
.
server1 is mapped to drive z: on my computer.
My code looks like this (verbatim)
<?php //attempt 1 $file = "\server1\abc\123\test.accdb"; $dbh = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb , *.accdb)};Dbq=$file"); //attempt 2 $file = "Z:\abc123\test.accdb"; $dbh = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb , *.accdb)};Dbq=$file"); ?>
both of these give me error:
SQLSTATE[HY024] SQLDriverConnect: -1023 [Microsoft][ODBC Microsoft Access Driver] ‘(unknown)’ is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
I am indeed connected to the server. Does anyone here have some wisdom to share?
Advertisement
Answer
As a diagnostic check, try using the same mechanism you’ve been using to invoke your PDO script to invoke the following script:
<?php $file = "\\server1\abc\123\test.accdb"; if (is_file($file)) { echo "File exists.rn"; } else { echo "File does not exist.rn"; }
That will test whether the account under which the script is running is allowed to access the network and “see” the file on the remote server. If it fails, then check the Windows rights for that account.
As a further test, you could try running that same script from the Windows command line using your regular user account (which presumably does have sufficient rights to access the network).