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.
So I have a php script that connects to a MySQL database that runs fine on my server and my schools server when it is ran. I currently have to have my script connect to another database but get the following error
Host "host" is not allowed to connect to this MySQL server
I did search and found the option to use GRANT ALL PRIVILEGES "." for the user but wanted to know if it is possible (Since I have to submit these files to the persons FTP) to run it after I upload the file to the ftp server. My guess is where the database is located as well. HTML runs fine off the ftp but when I try to open the php script All I see is just the code instead of anything running. Is it impossible to run a PHP script off the ftp using ftp://ftpserver/script.php?
Or am I looking at this the wrong way?
I apologize for any beginner annoyance as I've never really worked with FTP and how they function when it comes to this.
Any help is appreciated.
I have a linux machine server, I am able to use php in it. I can only connect to it using a putty command prompt or an FTP program. (basically have limited access).
Is there a way I can use a free database (like mysql)? I'm don't think I can install it on the root folders because of permissions, that's why I was thinking maybe there is a database tool that works as a standalone file, and each database is created as a resource file. That way there is no need for an installation, and you can keep the whole thing in some sub folder in the location where I do have access.
Is this possible?
I am hoping for something like, I download a file, place it on some folder after transferring it through FTP program. Then use php code to create a database and insert/delete records.
And every database created is stored as a file somewhere beside the database tool.
Use sqlite I think is just what you are looking for.
http://www.sqlite.org/about.html
I have a local database, and all the tables are defined. Eventually I need to publish my data remotely, which I can do easily with PHPmyadmin. Problem however is that my remote host doesn't allow remote SQL connections at all, so writing a script that does a mysqldump and run it through a client (which would've been ideal) won't help me here. Since the schema won't change, but the data will, I need some kind of PHP client that works "reverse".
Edit: I want this as an automated solution, so I don't have to copy/paste the SQL everytime I make a change!
My question is if such a client exists and what would be recommended to use (by experience). I just need an one way trip here, from my local database (Rails) to the remote database (supports PHP), preferable as simple and slick as possible. Thank you for your replies, comments and feedback!
I believe phpmyadmin has the ability to upload and execute an SQL file, so you can just import a mysqldump via that means.
I am getting daily data dump via e-mail, which is being processed by Access (based on the Outlook rule, VBA is extracting the attachment and running Access procedures, so I get a report).
As data dump is getting bigger and bigger, and having in mind that Access is run locally which consumes my resources, I want to set up a PHP/MySQL server to make it more efficient.
The first challenge I face is how to connect Outlook rule with PHP execution? (as I will have Outlook set up on the Windows based machine, with apache/mysql set up (WAMP))
Anyone can share some insights on how to start PHP execution from Outlook?
Thanks for the help!
Srdjan
If you have an existing setup using Access and VBA, and you just need a better database behind it, could you not just use MySQL without PHP and use the MySQL ODBC driver instead of the Access connection you are using at the moment (assuming you are currently using ODBC to connect to the access database)
This way you wouldn't even have to have mysql running locally if the hit is too high on your local machine and it should be pretty straightforward in that you shouldn't have to make to many changes to your vba code.
Of course, whether this will do it depends on what else is going on in your access db
If not you could try using php and using the PHP Command Line Interface (CLI) which you should be able to call as an external executable from Outlook. Just pass php.exe the name of the php script you want to run
UPDATE:
I am not a VBA expert by any means but it looks like the shell function would let you run the PHP CLI from within VBA
Shell("path/to/php.exe phpscript.php")
http://msdn.microsoft.com/en-us/library/xe736fyk(VS.71).aspx
Of course this will only work if you can get to php.exe on the wamp machine (ie is a local machine or you have network access to the appropriate folder)
Alternatively, if the Wamp server is to be a separate machine then you could trigger the php script to be run by calling a url. I think the XMLHTTP object will do this for you
Dim xmh As Object
Set xmh = CreateObject("MSXML2.XMLHTTP")
xmh.Open "GET", "http://urlofphpserver/script.php", False
xmh.Send