I did install php-odbc... because calls to odbc_connect failed with an error like "call to nonexistent function"
When I tried your sample code, after a few syntax corrections, I got this error: Connection to database failed.SQLSTATE[IM002] SQLConnect: 0 [unixODBC][Driver Manager]Data source name not found, and no default driver specified Since DB2 is actually on a different machine, were do I find the syntax definitions for that? I didn't expect it to work because DB2 is on a different machine... but that does show I have PDO. :-) How do I tell if I have ODBC ibm-db2 driver/thingy? I did find the PECL file ibm-db2-1.9.0 but when I do the ./configure command, I get an error : checking for egrep... grep -E checking for a sed that does not truncate output... /bin/sed checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed checking whether gcc and cc understand -c and -o together... yes checking if compiler supports -R... no checking if compiler supports -Wl,-rpath,... yes checking build system type... s390x-redhat-linux-gnu checking host system type... s390x-redhat-linux-gnu checking target system type... s390x-redhat-linux-gnu checking for PHP prefix... /usr checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext checking for PHP extension directory... /usr/lib64/php/modules checking for PHP installed headers prefix... /usr/include/php checking for re2c... no configure: WARNING: You will need re2c 0.9.11 or later if you want to regenerate PHP parsers. checking for gawk... gawk checking for IBM_DB2 support... yes, shared checking Looking for DB2 CLI libraries... checking in yes... checking in yes/lib64... checking in yes/lib32... checking in yes/lib... not found configure: error: Please reinstall the DB2 CLI distribution Reinstall DB2 CLI? I think I need something else... DB2 is on a different machine... but I understand I need to install some sort of client on this machine that has the PHP scripts on it. So, I'm getting there, albeit slowly. :-) My next challenge? Where to find, and how to install that piece.... Cheers On Fri, Oct 8, 2010 at 01:06, Joachim Schmidt <joachim.schm...@oberquembach.de> wrote: > 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/ > ---------------------------------------------------------------------- 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/