Connect PHP to AS400 with ODBC or DB2

2019-06-05 03:33发布

问题:

I'm trying to connect my WEB server to AS400. The web server has not DB2 library neither ODBC library.

I have installed XAMPP in my Windows computer, and one of my colleagues also did. He has Client Access on his Computer.

We both installed: - XAMPP - ibm_data_server_driver_package_win32_v10.5.exe

We tried to install PECL DB2 extension (LINK) but unsuccessfully (got error ".\php.exe appears to have a suffix .exe, but config variable php": seems that nobody has solved this problem on Windows...).

Then we saw that XAMPP has the ODBC Module already on it, so we tried to estabilish a connection with obdc_connect. Referring to THIS question we are now able to connect to AS400 using his computer with Client Access Drivers using:

$user = 'USER';
$password = 'PASS';
$hostname = '192.168.1.30';
$server="Driver={Client Access ODBC Driver (32-bit)};
         System=$hostname;
         Uid=$user;
         Pwd=$password;";

odbc_connect($server, $user, $password);

With my computer I tried to use the IBM data server driver already installed using:

$user = 'USER';
$password = 'PASS';
$hostname = '192.168.1.30';
$server="Driver={IBM DB2 ODBC DRIVER};
         System=$hostname;
         Uid=$user;
         Pwd=$password;";

odbc_connect($server, $user, $password);

and I get always this error:

Warning: odbc_connect(): in C:\xampp\htdocs\test.php on line 11

When I've tried with IBM DB2 ODBC DRIVER on my colleague's computer, I've also got the same error.

What is this error? No information is specified. We would like to use db2_connect instead of odbc_connect. What should we do to install this extension? I asked my ISP to install the db2 extension on the WEB server but I'm still waiting... maybe he also encountered some problems (the WEB server is a UNIX machine).

Any help is much apprecciated!