PHP Problem connecting php and .mdb with pdo-odbc - php

I have php program that requires MS Access, so I had to use odbc. Locally, using DSN it was working fine:
$db = new PDO("odbc:MyDSN");
I also have no problem when I put the php and odbc at the server and access it remotely:
$db = new PDO("odbc:DRIVER=MDBTools; DBQ=Data.mdb;");
But I can't afford to use it for some reason. I want to put php on the server together with the database but I want to place odbc (or the odbc driver) on the client, something like this:
$db = new PDO("odbc:{127.0.0.1\foo\bar\odbc.ini}; DBQ=Data.mdb;");
I can't seems to work with it for a while. I'm using Ubuntu 64bit as server, and Windows 7 as client
UPDATE 1: I found a way to do it, but it needs to modify the PHP itself (Classes,structure,etc.) I hope someone can help me to get alternative solutions
UPDATE 2: Another solution, but requires third party software.

But I can't afford to use it for some reason. I want to put php on the
server together with the database but I want to place odbc (or the
odbc driver) on the client, something like this:
The driver must be loaded by PHP, which is the "client" in this scenario. Means, you'll have to find an appropriate MSAccess ODBC driver for Ubuntu.
Check this SO thread:
ODBC connection to MS-Access on Ubuntu

Related

SQL Server setup with PDO on Redhat

I am currently creating a PHP script to copy some data onto a Microsoft SQL server from a MySQL server. I decided to use PHP with PDO since I thought it would be a really quick process (famous last words).
The Mysql side is completed but I am completely stuck on the MS SQL side on how to get everything installed correctly. My work script server has several different drivers installed (freeTDS, Microsoft ODBC Drivers) and I am not sure how to setup this new MS SQL server in PHP especially to use PDO instead of the direct ODBC functions PHP has.
The work server uses PHP 5.3 which has caused problems with perl rejecting to install sqlsrv/pdo_sqlsrv since the server doesn't run PHP 7.1 or greater.
My main questions being:
Which driver should I use to setup the PHP 5.3 MSsql driver on a redhat server that will work with PDO?
What should my PDO connection string look like?
This is what I have now:
$connectString = "sqlsrv:server=$host;Database=$schema;charset=$charset";
Is it really necessary to define the server connection in the ODBC driver before hand?
Sorry I don't have more research into this it seems there are many ways to bring in MSsql in PHP and I'm not sure which path to go down for my specific version of PHP!
I use this for MSSQL connection with pdo
$db = new PDO("sqlsrv:SERVER=$dbhost;DATABASE=$dbname", $dbuser, $dbpassword);

Connecting to SQL server database with PHP and Windows drivers

I was trying to connect to a Microsoft SQL Database with PHP using the mssql set of functions that WERE in php. Since I am using php 5.5, these functions are deprecated I think, but I read that there is a solution, which is downloading the drivers windows is providing. I downloaded and installed them from the following link:
https://www.microsoft.com/en-us/download/details.aspx?id=20098
Now the only thing is unclear to me is how to use them. Do these drivers re-activate the mssql (which I am sure it is not the case since I tried the code using mssql_connect and it threw a php error saying that the function could not be found)?
Can anybody give me an example of a MSSQL connection with these drivers?
Thanks a lot for your time and help!
Cheers!

Connect to a remote Windows Sybase database from Ubuntu via PHP

Ubuntu 12.04 LTS Precise
I'm trying to use PHP to connect to a remote Windows Sybase database. Let us assume Windows 7 Enterprise SP1. I'm currently doing this in PHP:
$db = sybase_connect("10.1.208.111", "$user", "$pass");
And I'm getting an error of:
Warning: sybase_connect(): Unable to connect to server: 10.1.208.111
I understand that the server I'm connecting to (10.1.208.111), needs to be in the interfaces file. I'm trying to figure out where that is, or even if I have one on the Ubuntu server (I'm still new to linux itself). I read that the path for the file is located in the SYBASE environmental variable. I don't know where that is either. Can anyone shed some light? I can offer more information if you need it, I just don't know what you need right off the bat.
PS: The windows machine has Micros RES installed on it. That's the database I'm trying to pull data from. Not sure if that matters.
The default installation directory for Sybase ASE in windows is C:\sybase, so your interfaces (interfaces.ini) should be located there.
For SQL Anywhere, the interfaces file is called SQL.ini, and it's location varies, but you should be able to do a search of your system drive to find it.
For SQL Anywhere you probably want to use the PHP apis that are provide by SAP Sybase. The SQL Anywhere documentation is a pretty good place to start, as it covers all the pieces that need to be installed to get SQL Anywhere to talk to PHP.
SQL Anywhere 11: SQL Anwhere PHP API
You may also be able to find good information over at the SAP Community Network site for SQL Anywhere.

Create a DSN for the function odbc_connect for Oracle

The information I have concerning the Oracle database O need to connect to using PHP through EasyPHP is the following: user, password, host, port, service. I'm new to ODBC. I tried to use the function odbc_connect, but I keep getting errors simply because I don't know how to make a DSN.
I tried using this:
$dns_db="DRIVER={DataDirect 32-BIT SequeLink 5.4};HOST=localhost; PORT=2399;ServerDataSource=maDB;"
But I don't know what {DataDirect 32-BIT SequeLink 5.4} means, and it seems like I need to know the database name so I can put it in the ServerDataSource.
How do I make this DSN thing?
That should be the driver name as it shows up in the ODBC manager. In my computer I have Microsoft ODBC for Oracle and Oracle in instantclient_11_2 to choose from:
Try to use a driver provided by Oracle; the Microsoft one lacks many basic features.
But I'd recommend you to create a system ODBC so you can assign a name of your choice and simply refer to it by such name. Additionally, that allows to configure additional options with the driver's GUI:
Last but not least, my final advice is to dump ODBC completely and use the OCI extension. Coding a PHP app with ODBC is frustrating.

Pervasive & Linux

I'm interested in quering a Pervasive DB server running on a Windows platform from Linux.
Would anyone happen to know if this is possible, what's required and what resources there are for me to read up on it?
Thanks!
What version of Pervasive are you using? All versions since v8 (including v9 and v10) support a Linux client which is included with the Pervasive.SQL server engine. V9 and V10 clients are also available for download from the Pervasive website (http://www.pervasivedb.com/Database/Products/PSQLv10/Pages/PSQLOverview.aspx). Once you've got a client installed on the Linux machine, you can create an ODBC DSN or use the Btrieve API to access the data.
Most database have at least a command line client to connect to database. check your brand of database to see if you have such tools. For example, Mysql has mysql command line client for making query to MySql database. Otherwise, another way is you might want to try setting up ODBC with Perl.

Categories