Connect to remote MS Access database from Linux Server using PHP - php

Does anyone know if it's possible to connect and query an MS Access database from a Linux Server using PHP?
If it is possible I'm thinking install ODBC driver on the Linux server, but will it work to connect to Access is the question. I've read it's possible with MSSQL.
My knowledge is very limited when it comes to any Windows related DBs so any advice much appreciated.

Yes, it's possible. I've done it using ODBTP, which took advantage of the ODBC driver on the (Windows) machine that hosted the Access database file.
It's also theoretically possible to use an ODBC driver on the Linux server to read an Access database on a Windows networking share if the Linux box can "see" it. However, I've never had very good luck with Access ODBC on Linux so I wouldn't recommend spending too much time trying to get it working.

Related

What to do about MS Access in PHP in Unix?

I need to pull data from MS Access 2007 (both mdb and accdb files) for a website written in PHP 7. The pages don't need to be dynamic or interactive. They just need to present data stored in the database.
Local development environment: Windows 7, IIS 7.5
Online server: A2 Hosting, Linux (CloudLinux Server release 6.9), Apache/2.2.34
The ADOdb webpage for Access says "Windows Yes, Unix No". I presume this means I can use ADOdb to connect to Access in my local environment, but not on the online server. I suppose I have the following options:
StackOverflow has some questions on this (1, 2, 3) with answers that give code for connecting to Access in PHP. Although the answers don't say so, I am guessing that that code will only work in Windows because if it were that easy to connect to Access in PHP in Unix, then ADOdb would do it! So if I'm right about this, then this is not a workable option.
The PHP Manual has a page on Database issues that says PHP can access Access, but it seems to only apply to either running in Windows or "running PHP on a Unix box and want to talk to MS Access on a Windows box". So this also does not appear to offer a workable solution for running the website online on a Linux server.
Extract the parts of the database needed into something else that can be accessed in Unix, such as CSV files, and use that as the database for the website. If I do this with CSV, I suppose I don't need ADOdb, but would just use fgetcsv(). This is an inelegant solution, but may be the best thing to do if there's not a way to access Access directly in Unix. (I could use MySQL instead of CSV, but that seems like a lot of unnecessary overhead.)
Run the pages on my Windows machine using ADOdb to access Access. Save the parts of the pages that come from the database as separate HTML segment files and include() them when the pages run online. (The script could detect which environment it's running in and if it's local, then access the database, and if online, then include() the HTML segment files.)
Move the online website from Linux to a Windows server, so PHP can access Access directly using ADOdb.
Convert the entire database from Access to something else, such as MySQL. This is not practical at this time, although that may be an option in the future.
Have I understood my options correctly? I've listed them in what seems to me to be the order of preference, so unless someone suggests otherwise, I guess I'll go with the third one (extract to CSV, use fgetcsv(), no ADOdb) since the first two won't work.
Thanks for your help.
The main problem is the ODBC driver. The {Microsoft Access Driver (*.mdb, *.accdb)} comes with Microsoft Access or the Microsoft Access Database Engine, which are both Windows-only.
However, there are alternate ODBC drivers that work on Unix and unixODBC. A popular open source one is mdbtools, which is limited, but can be used to connect Access to PHP on unix using PDO and ODBC. There are also commercial alternatives that are more fully featured.
Once you've got that working, it shouldn't be a problem to use the ODBC driver in PHP. Note that on shared hosting, this might not be possible.
Alternatively, you can use a php-jdbc bridge with UCanAccess. This might still be all-open-source and more fully-featured than mdbtools, but is more complex to set up correctly.
You don't need to convert "the entire database" from Access to use Mysql, just the tables. You can then link them back into the Access database using the MySql odbc connector and so long as the table names are the same you won't even notice the difference, all your forms, queries and everything will work.
You would then have MySql server running on your local machine which, if you create a user with the right permissions and port forward through your router (directing traffic from port 3306 or whichever port you assign to your server, to your machine) and allow the traffic through your firewall, your website can then access, read and write to your database.
If you want to query the database from php mysqli_query will work just fine. Most websites that run from data run using MySql, so this is a future proof solution too.

Editing MS Access Database using PHP on Linux

we have a Tool for managing the booked time at the different prjects of our customers an other things based on MS Access and we want to continue with it. Just for a better comfort I've made an PHP based Tool that is able to work with that database but it runs local on a windows system. Now I'd like to run it on our office webserver but that is a Linux system.
I use the PDO extension odbc and found the following docu to use the odbc extension on linux:
https://gist.github.com/amirkdv/9672857
But this only allows me to read the databse.
Do anybody knows a way to get full access to a MS Access Databse on a Linux system?
I'm looking forward to your answers^^
The Access database (not the application) doesn't "run" anywhere, it's a file, so all you need an SMB share which, on Linux, is what Samba provides.
If you wish to run the Access application on Linux, you will need Wine.

PHP Remote Connection to MS Access 2016 Database

I'm working on getting information from a submitted HTML form entered automatically into an Access 2016 database. My understanding of this process is limited, so I ask that you bear with me.
The HTML form is stored on a 64-Bit Windows Server 2008 R2 DC that is doubling as a Web Server. PHP has also been installed and configured on this Server.
The database is stored on a separate 64-Bit Windows Server 2008 R2 Virtual Server.
I've seen plenty of articles regarding PHP and SQL (MySQL, SQL Server, etc.) but very little about PHP and MS Access. I understand now that I need to set up an ODBC Connection but that's where I begin to get lost.
Questions:
Am I correct in thinking the ODBC Connection needs to be set up/configured on the Web Server?
Am I correct in thinking only the 64-Bit ODBC Driver is required? (Although I'm pretty confident this is correct, I have this nagging doubt that, because some 32-Bit computers will be accessing the HTML form, there will also be a need to have the 32-Bit ODBC Driver. It may seem silly but I'd like confirmation with regards to this.)
Where is the ODBC driver? I did a search and it brought me to a download for "Microsoft Access Database Engine 2010 Redistributable". Is this what I'm looking for? (I admit that, unless it's pretty obvious, I tend to feel I'm in the wrong place. And unless someone can confirm that 'Redistributable' is the same as 'ODBC Driver', I'm inclined to think I'm looking at the wrong thing.)
Thanks for any help!
Eric
Since all of the code running on your web service is x64, then yes of course you will need the x64 Access (ACE) odbc driver.
You are correct in choosing Access Database Engine 2010 Redistributable. In fact, you might as well use the 2013 one. Don’t forget to choose the x64 version.
The fact that x32 or x64 computers connect to the web site is not relevant – the server and web code is running as an x64 in process and thus you need to use the x64 odbc driver for Access.
Also while the accDB access file CAN BE on the other server as you point out, that file name MUST be in a folder that that the web server has full rights to. So you not using an IP address, but a FULLY qualified windows path name to a legal windows folder and a legal windows file (in this case the access accDB file). So keep in mind that you do not connect to an Access database, but in fact are opening a windows file. You don’t connect to a word document, you open it. You don’t connect to a PowerPoint file, you open it. And you don’t connect to an Access accDB file, but your software (the odbc driver) will in fact do a DIRECT windows OS file open of the Access file.
So unlike a web site or say SQL server that allows a connection via a socket (tc/ip + a IP address), an Access file is NOT a socket based system, but is in fact a plane jane windows file that will be opened in-process by YOUR software. So the opening of the Access file occurs on the web server – even if that Access accDB simply a USB jump drive plugged into that server, or some other file share on the servers network. We talking about the code on the web server opening that Access file – that Access file thus must be located in a folder that is directly accessible by the web server code running.
Thus you don’t need the ACE data engine installed on that second server for example – only where the code is running do you need the ODBC driver. The significant issue here is that most ODBC drivers allow you to “connect” to some server with a database engine. Because Access is file based then BOTH the ODBC driver and the data engine MUST be installed on the computer that uses the ODBC driver. That driver thus will ALWAYS launch a copy of the data engine local and on the same computer using the ODBC driver. When you use say a SQL driver, you requite a local copy of the SQL database engine – with Access you do!

How to connect hive server with php

I have installed Hadoop 2.7 and Hive 1.2.1 on Ubuntu 14.04 that manage sensor data. I have already stored data sensor to Hive.
My Project is to make a web server from it and a web application that can show data record from hive table.
My problem is How to connect database Hive with php? I found Apache Thrift to do that. but I dont understand (Im new at Hadoop things)
Can someone give me tutorial or step by step to solve my problem
One way to try is to use ODBC. If you do not know, how to use ODBC. Read more on that via: Using PHP can I use a JDBC or ODBC connection?
Once, you can setup your ODBC connection, you can use ODBC to connect to the hiveserver. To install, ODBC here two links on how to do that on Cloudera resp. Hortonworks.
http://www.cloudera.com/downloads/connectors/hive/odbc/2-5-12.html
http://hortonworks.com/hadoop-tutorial/how-to-install-and-configure-the-hortonworks-odbc-driver-on-windows-7/

Remote MS ACCESS connection with PHP ODBC on CentOS [duplicate]

Does anyone know if it's possible to connect and query an MS Access database from a Linux Server using PHP?
If it is possible I'm thinking install ODBC driver on the Linux server, but will it work to connect to Access is the question. I've read it's possible with MSSQL.
My knowledge is very limited when it comes to any Windows related DBs so any advice much appreciated.
Yes, it's possible. I've done it using ODBTP, which took advantage of the ODBC driver on the (Windows) machine that hosted the Access database file.
It's also theoretically possible to use an ODBC driver on the Linux server to read an Access database on a Windows networking share if the Linux box can "see" it. However, I've never had very good luck with Access ODBC on Linux so I wouldn't recommend spending too much time trying to get it working.

Categories