Solved

Querying Remote MS Access DB on Linux via PHP

Posted on 2011-03-02
10
511 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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 500 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

636 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