What’s wrong with my following code for connection to a DB2 database?

413550 pts.
Tags:
IBM DB2
PHP
I'm trying to connect to a DB2 database with PHP. I have a code but it's not really doing anything for me. It's not returning an error message but just breaks JavaScript later in the page. Here's the code:
include(TEMPLATEPATH.'/inc/library/adodb_lite/adodb.inc.php'); 
   $DBName = 'DBNAME';
   $Host = 'IPADDRESS';
   $User = 'USER';
   $Password = 'PASS';

   $db = ADONewConnection('db2');

   $dsn = "driver={IBM db2 odbc DRIVER};Database=$DBName;hostname=$Host;protocol=TCPIP;uid=$User;pwd=$Password";
     if ($db->Connect($dsn)) {
     echo "<div style='color:green;font-size:21px;'>Connection Successful.</div>";
             } else {
                 echo "<div style='color:#cc0000;font-size:21px;'>Connection Failed db->Connect(dsn)</div>";
                 echo 'SQLSTATE: '.$db->ErrorNo()."<br>";
                 echo 'Message: '.$db->ErrorMsg()."<br>";
             }
Thanks for all the help!

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • TomLiotta

    It's not returning an error message but just breaks JavaScript later in the page.

    I don't quite understand. If there is no error returned for the code that you posted, but later code fails, why not show us the code that fails and describe what the failure is?

    Tom

    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: