Hi I have been trying to connect to a DB2 database on an IBM AS400 system. I
manage to get connected using ODBC however it is slow at connecting and
every time the page is refreshed it seems to have to connect again. Any help
would be appreciated.

I use the below code to connect.
In a file called AS400dbconnect.inc


        $host = "LAWSON01";
        $username = "MYUSERNAME";
        $password = "MYPASSWORD";
        $link= odbc_connect($host, $username, $password,SQL_CUR_USE_ODBC)

                or die (odbc_errormsg() );

Then in a file called as400.inc
The following cote is in it 



if ($link)
  echo "odbc connected<br>";
  $sql =  "select * from exrcvbuf"; 
  //this function will execute the sql satametn in  
  //correspondance to the table in the db
        or (odbc_errormsg());
  echo "odbc not connected<br>";

        $Fields = odbc_num_fields($exc); 

        print "<table border='1' width='100%'><tr>"; 

        // Build Column Headers 

         for ($i=1; $i <= $Fields; $i++)
                printf("<th bgcolor='silver'>%s</th>", odbc_field_name(

        // Table Body 

                while( odbc_fetch_row( $exc ))
                        print "<tr>"; 
                        for($i=1; $i <= $Fields; $i++)
                                printf("<td>%s</td>", odbc_result( $exc, $i
                        print "</tr>"; 
                        print "</table>"; 
                        print "<b> Your request returned $Outer rows!</b>"; 



  echo "selection failed<br>";

It is running in and apache server with php set up using the .dll method.
Ian McGhee
Junior Analyst Programmer
Richard Lawson Autologistics Group
Telephone: 01382 560259

J B Cartwright, G D Frost and R J Hunt have been appointed as joint
administrators of Richard Lawson Autologistics Limited, on 14th September
2004, to manage its affairs, business and property. As such they contract
without personal liability. Both J B Cartwright and G D Frost are
licensed to act as Insolvency Practitioners by the Institute of Chartered
Accountants of Scotland and R J Hunt is licensed to act as an Insolvency
Practitioner by the Institute of Chartered Accountants in England and Wales.


If you are not the intended recipient of this message, you should not
review, print, re-transmit, store or take any actions based on the content
of this e-mail or any attachments. Please contact the sender by e-mail and
delete the material from any computer.

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to