Connecting a DB2 database from a Webserver in PHP Wordpress - php

We have got a website that has been written in PHP (Wordpress)
It is running on a VPS that has got the DB2 module installed.
But we are unable to get the website connecting with the DB2 database that is on the I5 (AS400) server to be able to preform SQL statements.
Currently the website we have got that is connected is in .asp and the person who did all that is no longer here.
I came across this article
Connect PHP to AS400 with ODBC or DB2
Which is a bit of a help.
But does anyone have some instuctions or step by step information about setting this up on the I5 (AS400) server and the website on the webserver. I have come across a IBM product call DB2 connect is this what I need.
Thanks

There are 3 versions of DB2: DB2 for Linux, Unix, Windows; DB2 for Z (mainframe); DB2 for IBM i. The machine you are calling i5 or AS/400 is running the IBM i operating system. The typical DB2 ODBC driver is probably for DB2 LUW. You want toe ODBC drivers for IBM i. These come with the product called IBM i Access for Windows. In earlier years, it was called Client Access for Windows.
The installer is on a DVD. The installation image is also on the IBM i server.
Map a network drive to QIBM\ProdData\Access\Windows on your IBM i.
Double-click cwblaunch.exe
Use the wizard to complete the install.
You can select to install only the ODBC driver by choosing 'Custom' install.

Related

Connecting IBM Cloud php app to IBM Cloud DB2

During the IBM Cloud Foundy upgrade to cflinuxfs3 a few things got missed, including providing a way to connect IBM Cloud php app to IBM Cloud DB2.
The provided buildpacks do not support DB2 connections and the instructions on IBM Knowledge Center are no longer valid.
Anyone knows how to connect IBM Cloud php app to IBM Cloud DB2 after the Sept 16th upgrade?
If your cloud solution does not supply a working extension for Db2 to work with your PHP in your chosen environment, that is not a matter for StackOverflow.
Instead, Use the github issues page(s) to work with your buildpack supplier and cloud vendor to build the required extension with the required toolchain, or pay someone to do the build and test and deploy to your instances.
If you use an IBM Db2 driver and and IBM written Db2 extension for PHP, then it is a CLI / ODBC application, and because of that, the configuration for SSL needs to follow the IBM-documented steps - all of which have the pre-requisite that you have a working PHP extension for Db2 that works in your environment, along with other pre-reqs.

How can I use PHP to connect to ODBC to DB2 on Windows 2003?

My old server:
- Windows 2003 Server
- IBM DB2 UDB Version 8.1
- ODBC: User DSN:
There is a .NET webapps connect to MYDB using ODBC, it is good now.
But Windows 2003 is end of support from Microsoft on this month. So, I want to move from it.
The problem: I don't know .NET at all. The current .NET webapps was closed source and I cannot contact to provider company (it was defunct).
I want to get all tables from DB2 from PHP (running in my Ubuntu 14.04 desktop). I like to use PDO ODBC to connect. But it seems to be over my skills. My desktop is on the same subnet LAN with Windows 2003 server (ping to and from is OK), telnet server2003 ip port 5000 is OK.
I am stuck after install ODBC, config something in my desktop... Nothing works.
Who helps me? Every help is appreciated. There are no words to show my appreciation!
In addition to configuring and troubleshooting PHP access to DB2 via PDO ODBC, you will also need to migrate your DB2 8.1 server and clients, if any, to a newer DB2 release level (IBM ended support for DB2 UDB 8.1 back in May 2009). Fortunately, IBM now offers a no-cost version of DB2 called Express-C, which is authorized for production use. The current release, DB2 Express-C 10.5 Fix Pack 5, can accommodate databases up to 15 terabytes in size.
If it turns out that your company has an active DB2 license available for your application, then forget about Express-C and install whatever DB2 server edition is covered by your license.
To move your data out of DB2 UDB 8.1, you'll need to export the contents of each table to a separate file and import them into the new database. The db2move utility can assist with this process by iterating through all the tables in your database, saving you from typing all those EXPORT statements yourself.
Once your DB2 data is migrated to a new database, you can install a DB2 client on your Linux PHP server and test your connectivity. To keep the file size down, IBM offers a variety of DB2 client downloads, which can add some confusion as to which one you need. For ODBC and PHP applications, you should download the IBM Data Server Driver Package or, to be safe, the larger IBM Data Server Client which contains all the drivers and client libraries. Be sure that the client you download is the same version and Fix Pack level as your DB2 server (e.g. 10.5 Fix Pack 5).
IBM's online documentation and the PHP manual have a bit of information about connecting PHP applications to DB2.

SQL Server Access from PHP (PDO) Not Working Despite Driver Installed & Enabled

I am trying to access an SQL Server.
UPDATE: In response to Clive's comments below I have also tried reinstalling the native ODBC driver but no change.
I've checked over all the questions I can find on this and everything seems to be in order. My server details:
PHP 5.4 (Managed via Plesk)
SQL Server 2008 R2 SP2
Windows Server 2008 R2
The latest mssql drivers for PDO are in the EXT directory and referenced in php.ini:
extension=php_sqlsrv_54_nts.dll
extension=php_pdo_sqlsrv_54_nts.dll
PHPINFO() gives the following:
PDO Drivers: mysql, sqlite, sqlsrv
pdo_sqlsrv support: enabled
sqlsrv support: enabled
My connection string looks like this:
$DSN = "sqlsrv:Server=myDbServer,1433;database=my-dbname";
$PdoOptions = array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
);
$sparklyGenericPdoObj = new PDO($DSN,'myUsername','myPasswurde', $PdoOptions);
But that just gives me the following error which links - in a roundabout way - to the drivers I already have installed (I've checked the version numbers):
PHP Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[IMSSP]: This extension requires the Microsoft SQL Server
2012 Native Client ODBC Driver to communicate with SQL Server. Access
the following URL to download the Microsoft SQL Server 2012 Native
Client ODBC driver for x86:
http://go.microsoft.com/fwlink/?LinkId=163712'
On this thread (reporting exactly the same error as me) is a solution which says that you can confirm the driver is installed by looking for the items I've mentioned above in PHPINFO: Not getting connected to Sql Server 2012!
Any help would be much appreciated!
Although it is a fairly old post, I've decided that it would be better to place my answer here instead of creating an other question...
after 3 weeks of research all over the Web and testing a lot of hypothesis around php installation, php code and drivers installation, I finally found the solution to this question.
THE PROBLEM:
I have an app that is installed on WIN SERVER 2012 SP2 and running under IIS.
The development of this app is made on a WIN 7 SP1 and running under 32-bit XAMPP 3.2.2. All of these are running PHP 5.6.
Everything is working fine on the server but I keep having this message when executed locally on XAMPP:
This extension requires the Microsoft ODBC Driver 11 for SQL Server to communicate with SQL Server
Even though I've installed this driver many times (with other php drivers found here, configure my php.ini to load php_sqlsrv_56_ts.dll and php_pdo_sqlsrv_56_ts.dll), it keeps returning me the same message...
The PDO command I've used to connect to distant MSSQL Server was:
$db = new PDO("sqlsrv:server=192.168.165.XXX;Database=testDB;", "userName", "passWord");
I have tried other drivers and it worked fairly well with ODBC driver;
$db = new PDO("odbc:Driver={SQL Server};Server=192.168.165.XXX;Database=testDB;", "userName", "passWord");
but I've found that there was some limitations with the later driver that I didn't experience with sqlsrv on the PROD server so I decided to push a little bit more my research to find a way to implement sqlsrv on my local machine...
THE INVESTIGATION:
Before connecting with PHP, I've tried to create System DSN (Data Source Name), with the ODBC Source Administrator (ODBCSA) application and test connection from there before trying to connect with my application.
Something pretty strange I have discovered with Win7, is that there are two different ODBCSA applications.
The 32-bit version of the Odbcad32.exe file is located in the %systemdrive%\Windows\SysWoW64 folder.
The 64-bit version of the Odbcad32.exe file is located in the %systemdrive%\Windows\System32 folder.
The 32-bit version of the ODBC Administrator tool displays 32-bit system DSNs, 32-bit user DSNs, and 64-bit user DSNs.
The 64-bit version of the ODBC Administrator tool displays 64-bit system DSNs, 32-bit user DSNs, and 64-bit user DSNs
Just to make sure what ODBCA your are using, check in Task manager under odbcad32.exe, if you see *32 on its right, that means its the 32-bit version.
At first, I executed the 64-bit ODBCSA, created DSN using the brand newly installed ODBC Driver 11, called ODBC_11_64 and test the connection using the ODBCSA. All worked fine. When I tested my code I received an other error message:
The specified DSN contains an architecture mismatch between the Driver and Application
Ok then, I tried to create an new DSN using the 32-bit ODBCSA. It was strange at first, when I've discovered that there was no version number aside some driver names and I received this error from the ODBCSA:
The setup routines for the ODBC Driver 11 for SQL Server could not be found. Please reinstall the driver.
and an other message:
Component not found in the registry
It was obvious that there was an installation problem and the later message point me in the right direction, the Registry...
Starting regedit as admin, I've found that all 64-bit ODBC drivers can be found here:
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI
All 32-bit ODBC drivers can be found here:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI
While trying to access the 64-bit key (\ODBC Driver 11 for SQL Server), I was able to display key values but when I tried to access the 32-bit key, I received this message:
Error Opening Key, ODBC Driver 11 for SQL Server Driver cannot be opened.
An error is preventing this key from being opened.
Details: Access is denied.
THE SOLUTION:
By right clicking on the 32-bit faulty key I was able to access permission interface. I was then able to add my username (I could also add a group) and granted full Control on the registry key.
I then came back to creating an new DSN using the 32-bit ODBCSA and ODBC Driver 11 for SQL Server, tested the connection with SUCCESS! :-)
I when back to my application and found that I was able to access the distant MSSQL SERVER using sqlsrv, on my local machine.
All along it was the driver installation package that was faulty! I should had install permissions to SYSTEM, users and administrators to the key has it did with the 64-bit registry key for this driver.
It was a pretty long story but I thought it was worth it, since a lot of persons tried to solve this complex problem, going in many different directions without success. Its also my contribution to all of you, who failed to find the solution but helped me in my investigation ;-)
i have fond some config in php.ini but was noted;
;extension=odbc
;extension=pdo_mysql
;extension=pdo_oci
;extension=pdo_odbc
remove “;” before, restart service, and it is worked!
In the end I solved this by installing the "Microsoft® SQL Server® 2012 SP1 Command Line Utilities" from here (SqlCmdLnUtils.msi):
http://www.microsoft.com/en-in/download/details.aspx?id=35580
No idea why this worked but there it is.

Mysqli and OCI8 activation on Redhat Linux

I am a novice developer in web, and I have the following situation:
One of my customers wants to 'activate' php extensions for mysqli and oracle (oci8) on a Redhat Linux server.
The actual goal would be to be able to communicate (connect) with a remote Oracle database , which is located on a remote Unix server.
What do I have to do in order to implement those requirements?
Also note that any actions have to be available for command line, since I only have remote access to the Redhat server.
Thank you in advance.
p.s:
The Redhat server already has the following installed:
Oracle 10g.2
php 5.1.6
Apache 2.2.3

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