title: DB2 PHP Connection
body: <p>Been digging through stackoverflow for a few days now. Need to connect to a DB2 database with PHP. The following code doesn't return the error message or any helpful information, and instead just breaks Javascript later in the page.</p>
  
  <pre><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-&gt;Connect($dsn)) {
       echo "&lt;div style='color:green;font-size:21px;'&gt;Connection Successful.&lt;/div&gt;";
               } else {
                   echo "&lt;div style='color:#cc0000;font-size:21px;'&gt;Connection Failed db-&gt;Connect(dsn)&lt;/div&gt;";
                   echo 'SQLSTATE: '.$db-&gt;ErrorNo()."&lt;br&gt;";
                   echo 'Message: '.$db-&gt;ErrorMsg()."&lt;br&gt;";
               }
  </code></pre>
  
  <p>As followed by <a href="http://adodb.sourceforge.net/" rel="nofollow">http://adodb.sourceforge.net/</a></p>