Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2002

    Unanswered: PHP ODBC_Connect to DB2 problem


    We have a problem using the PHP unified ODBC function odbc_connect() to access a remote database :

    We have a server running a DB2 UDB database for Linux

    We are attempting to access this database from an application server that is running PHP and Apache on Linux. On this server we have installed DB2 Connect and the DB2 Application Development Client.

    On the application server we have catalogued the remote database as follows:

    Database Directory

    Database alias = WEBPRD01
    Database name = WEBPRD01
    Node name = MYBBB01
    Database release level = 9.00
    Directory entry type = Remote
    Catalog node number = -1

    Node Directory

    Node Name = MYBBB01
    Protocol = TCPIP
    Hostname =
    Service Name = 3700

    From the command line we are able to connect to the database server successfully and issue an SQL select statement.

    However, when we try to access the remote database server via the following PHP script we get the following error:

    Warning: odbc_connect(): SQL error:, SQL State $ in SQl Connect

    PHP Script


    $dsn = "WEBPRD01";
    $user = "******";
    $password = "*******";

    $conn = odbc_connect($dsn,$user,$password);

    We have compiled PHP with the appropriate "--with-ibm-db2=/home/db2inst1/sqllib" configuration parameter.

    It seems as though the problem revolves around the PHP unified ODBC function odbc_connect() and its ability to connect to a remote database.
    Could anybody give us any clues as to what might be the problem ?

    Many Thanks in advance for any help you can offer

    Software Versions

    Application Server

    Linux: Red Hat 7.3
    Apache: 1.3.29
    PHP: 4.3.9
    DB2 Connect : DB2 Connect Personal Edition 7.2

    Database Server

    Linux: Red Hat 7.3
    DB2 : DB2 7.1 Fixpack 7 (DB2 v7.1.0.68)

  2. #2
    Join Date
    Nov 2002

    Smile Problem Resolved

    We have resolved our own problem.

    For the info of others, the problem was due to the fact that the user id the webserver was running as did not have access rights to the databases, despite the fact that we were using the correct user and password within the odbc_connect call in the PHP script.

    Hope this helps others in the future !
    Last edited by tnugent; 11-25-04 at 12:43.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts