Jump to content

Connecting Db2 To Php


madsovenielsen

Recommended Posts

Hey all.I have installed IBM DB2 and i want to connect php to my database. i have found some info on php.net and such. but im having a hard time connecting.

<?php		  //From php.net		  $database = "TEST";		  $user = "db2admin";		  $password = "********";		  $conn = db2_connect($database, $user, $password);		  if ($conn) {		  echo "Connection succeeded.";		  db2_close($conn);		  }		  else {		  echo "Connection failed.";		  }?>

i cant find any entries for db2 in php.ini so i guess its configured/enabled by default. (am i wrong?)i have created and configured a database in the controlcenter tool and created a table.im getting a http error #500 when i run the above script through apache 2.2if theres someone with db2 experience please give me some info. /mads

Link to comment
Share on other sites

I doubt an extension like that is enabled by default. A 500 response just means that PHP had an error, what was the error? It should either print an error message in the browser or use an error log. If you're using IE to test, you need to disable "friendly" HTTP errors, if that is enabled instead of telling you the actual error message it will just say a 500 response was returned.From the manual:

db2_connect(PECL ibm_db2 >= 1.0.0)
You need the PECL ibm_db2 package, version 1.0.0 or greater.
Link to comment
Share on other sites

I doubt an extension like that is enabled by default. A 500 response just means that PHP had an error, what was the error? It should either print an error message in the browser or use an error log. If you're using IE to test, you need to disable "friendly" HTTP errors, if that is enabled instead of telling you the actual error message it will just say a 500 response was returned.From the manual:You need the PECL ibm_db2 package, version 1.0.0 or greater.
First let me say that i really appriciate your help. i will look into the PECL package. thanks
Link to comment
Share on other sites

i found the pecl package for windows. its matching my php version. i extracted the dll to \ext\ i now have a entry for db2 in my phpinfo();EnvironmentDB2INSTANCE DB2i also added this to the php.iniextension=php_ibm_db2.dllwhen i run my php script for connecting to the db im getting this output from the script: Connection failed.i guess its progress from the HTTP #500 Error :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...