Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Querying Remote MS Access DB on Linux via PHP

Posted on 2011-03-02
10
Medium Priority
?
606 Views
Last Modified: 2013-09-05
I have an MS Access database stored internally on our network in an .mdb file. I want to connect to and query this database via PHP from a remote location (internet).

Here is one way I've come up with to get the mdb file onto the internet: I am using GoodSync to sync the .mdb file to our external web server (linux) twice a day. This may give us downtime during syncs. I could live with this if there is not a better way. But the main problem with this is that because the server is linux so ADODB does not work with access files under linux.

While under windows I used this to successfully connect to the MDB file, but it was stored on the local machine and used a driver to interface with it:
  define("MDB_TAPIT_SOURCE",						"\\\\techsprt\\tapitw32\\DATA\MAIN\\Tapitdb.mdb");
  define("MDB_DATA_SOURCE",							"Driver={Microsoft Access Driver (*.mdb)};Dbq=" . MDB_TAPIT_SOURCE);

odbc_connect(MDB_DATA_SOURCE, "","");  // This called for the connection

Open in new window

0
Comment
Question by:mtaylor584
  • 5
  • 3
10 Comments
 
LVL 3

Expert Comment

by:wwwdeveloper2
ID: 35023545
A couple of initial thoughts here:

Could you setup a shared directory on the remote computer on your network and store the access file in it and then map a network drive from the linux machine to the shared directory?  This should allow the linux server to access it via a drive.  That might be able to eliminate the syncing you are doing right now.

I haven't used ADOdb class library for PHP, but it is supposed to be able to connect to access databases.  Here is an article describing the install and information on how to use it:

http://www.databasejournal.com/features/php/article.php/2222651/An-introduction-to-the-ADOdb-class-library-for-PHP.htm


Here is some example php code on how to connect to the access database using ADOdb and a drive path:

http://code.activestate.com/recipes/163447-microsoft-access-database-connectivity-dsn-less/

Good luck, I hope this helps.  If you have any other thoughts or questions, just let me know.
0
 
LVL 3

Expert Comment

by:wwwdeveloper2
ID: 35023574
Sorry, I pasted the wrong url into the example code.

Connecting to access via the ADOdb class should look like this:

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


Here is a manual for it with code examples:

http://phplens.com/adodb/code.initialization.html#access
0
 

Author Comment

by:mtaylor584
ID: 35023713
Hi there!

I suppose I didn't clarify this, but the linux server is not on our domain, it is actually hosted by rackspace so it's outside of our network completely. Without a VPN I am not sure you can map a drive on a remote computer (in this case a linux box).

That would have likely solved the issue otherwise. Let me know your thoughts.
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

Author Comment

by:mtaylor584
ID: 35023724
And as I mentioned before, I don't believe ADOdb for MS Access Databases works on Linux as you'll see here under "Databases Supported"...I could be wrong:

http://phplens.com/lens/adodb/docs-adodb.htm
0
 
LVL 3

Expert Comment

by:wwwdeveloper2
ID: 35023753
Ok, well that is all I had.  Maybe somebody will be able to help.

Good luck
0
 

Author Comment

by:mtaylor584
ID: 35030122
Thanks for trying wwwdeveloper2.

Anybody have any suggestions? Do I need to install drivers on the linux box to be able to query the .mdb?

I have spent many hours on what seems like a very simple issue. Connecting to a Microsoft Access DB via PHP on a Linux webserver sounds like a very common scenario.
0
 

Author Comment

by:mtaylor584
ID: 35030356
The best method to do this would be to somehow 'host' the .mdb file that is currently being written to on the Windows machine in our network. This would allow us to query the database in realtime. I am currently able to interface with it via PHP on our internal network via a UNC path (//server/path/to/file.mdb), but this does not allow me to query it outside of our network.
0
 
LVL 51

Accepted Solution

by:
Steve Bink earned 1500 total points
ID: 35043264
You could create a local web service that queries the Access file for you.

Access was never really meant to serve in the capacity you want.  The best option would be to migrate it to a real database service, a-la MSSQL or MySQL.
0
 

Author Closing Comment

by:mtaylor584
ID: 39468873
Unfortunately the problem was never resolved. Creating a web service was the best suggestion thus far.
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question