Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2010
    Posts
    4

    Unanswered: how connect DB2 With PHP... Fatal Error try Connect.

    hi, i install the pecl extensions of ibm_db2 in my php, but give me fatla error on run my page.

    this is the error:
    Fatal error: Call to undefined function db2_connect() in C:\AppServ\www\multivpos\configs\bd.php on line 7

    i copy the php_ibm_db2.dll in my folder php, C:\AppServ\php5\ext, and i configure the php.ini file, adding line "php_ibm_db2.dll" in php.ini

    my php file to connect:
    PHP Code:
    <?php
    $database 
    'SAMPLE';
    $user 'db2admin';
    $password 'apassword';
    $hostname 'localhost';
    $port 50000;
    $connection db2_connect($database$user$password);
    if (
    $connection)
    {
    echo 
    "Connection succeeded."."\n";
    }
    else
    {
    echo 
    "Connection failed.<br />";
    echo 
    'SQLSTATE : ' db2_conn_error() . '<br/>';
    echo 
    'Message : ' .db2_conn_errormsg(). '<br />';
    }
    please help me how connect, fix the error.
    Last edited by clavijo83; 06-23-10 at 17:31.

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Your PHP installation/web server can't find the library. So you must be missing some step in the installation. I am not using Windows, so I can't be more specific, though.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  3. #3
    Join Date
    Nov 2004
    Posts
    54
    Another approach is to use ODBC.

    Code:
    $dsn = "batchquality";
    $user = "";
    $pass = "";
    
    $conn=odbc_connect($dsn,$user,$pass);
    if (!$conn)
      {exit("Connection Failed. Something is messed up in the data file: " . ODBC_ERRORMSG($conn));}
    Just config a DSN to connect into your DB and then go.

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Using the ODBC driver is a rather bad idea. That driver has several bugs and doesn't support all data types, for example. So I would only use it as a last resort to see if something fundamental is wrong in the system (like DB2 not installed).
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

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