hi, have you checked, e.g. with phpinfo() , wether PDO (odbc) and PDO Driver for ODBC (ibm-db2) is enabled? if it is, try this: ... ... $database= "your-DB"; $username="your_dbuser"; $password="your_DB2pw";
try { $dsn="odbc:$database"; $conn = new PDO($dsn, $username, $password); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(Exception $e) { $sqlerror = $e->getMessage(); $SQLState = strstr($sqlerror, "SQLSTATE"); $SQLState = substr($SQLState, 9, 5); $conn = NULL; } } else { } if ($conn == 0) { echo("Connection to database failed."); printf("%s\n", $sqlerror); } else { echo("Connection to Database Server $database established."); } return $conn; } ..... have fun! Joachim Schmidt Am 07.10.2010 18:24, schrieb Donald Russell:
I'm running RHEL 5.5 on zVM and DB2 running on a different host system (also zLinux, but that doesn't matter) > From the first system, I want to access DB2 using PHP. (Not via Apache, I'm using PHP for some scripting) Seems straightforward enough.... but I need the IBM Data Server Driver for ODBC and CLI (CLI Driver) installed on the same machine PHP is running on.. makes sense. OK, so I downloaded it from IBM.... but I don't know how to install it. :-( It's a tar.gz file, which I un-tarred, expecting to find a make file or some instructions... I didn't find any. :-( Can somebody point me to, or explain how to install this Driver... and then how to actually use it? i.e. I know I'll need to code the driver name or something in the odbc_connect statement like Driverr="{IBM DB2 ODBC Driver}" Thank you ---------------------------------------------------------------------- For LINUX-390 subscribe / signoff / archive access instructions, send email to lists...@vm.marist.edu with the message: INFO LINUX-390 or visit http://www.marist.edu/htbin/wlvindex?LINUX-390 ---------------------------------------------------------------------- For more information on Linux on System z, visit http://wiki.linuxvm.org/
---------------------------------------------------------------------- For LINUX-390 subscribe / signoff / archive access instructions, send email to lists...@vm.marist.edu with the message: INFO LINUX-390 or visit http://www.marist.edu/htbin/wlvindex?LINUX-390 ---------------------------------------------------------------------- For more information on Linux on System z, visit http://wiki.linuxvm.org/