Broken Pipe on iSeries when using PHP

68 Views Asked by At

I'm trying to write some PHP code that is trying to connect into our iSeries, but I'm getting the error 'Broken Pipe'. I've tried looking through ibm pages to see some examples, but I can't find anything. Can someone explain to me what I am doing wrong. Here is my code :

<?php
/* Connect to server */
$conn = i5_connect("IPADDRESS", "USERNAME", "PASSWORD");
if (!$conn) {

    $error = i5_error();

    echo " Error during connection\n";

    echo "<BR> Error number: ".$error["num"];

    echo "<BR> Error category: ".$error["cat"];

    echo "<BR> Error message: ".$error["msg"];

    echo "<BR> Error description: ".$error["desc"];

    trigger_error("I5 connection fails", E_USER_ERROR);

} else {

    echo " Connection OK ";

}
?>
1

There are 1 best solutions below

0
On

I believe that the db2_xxxx functions require the DB2 Connect client. I do not know if this is true of the i5_xxxx functions. Whenever I have connected to DB2 for i using PHP, I have always used ODBC. That driver is free with iACS. The DB2 Connect product is usually prohibitively expensive unless you are working for a very large company.

Here is a sample working connection string:

// link to as400
$dsn = "DRIVER=iSeries Access ODBC Driver;SYSTEM=" . $asdb_host . ";DBQ=" . $asdb_name;
@$link_id_400 = odbc_connect ( $dsn, $asdb_uname, $asdb_pw );

Where $asdb_host is the host name for your IBM i server, $asdb_name is the library name, $asdb_uname is the user id, and $asdb_pw is the password. Once the connection i made using ODBC, then you can use other ODBC functions to access the data. One note that may be of interest, using column numbers to resolve columns is much faster than using column names!