Hi, I'm kind of a newbie with DB2 but have done various PHP/Apache2/mySQL installations in the past for school.. Right now I'm running on SUSE Linux Enterprise Server 10 on 64 bit hardware. Here is a list of the software that I am using:
Apache2.2
unixODBC V2.2.11-21.4
PHP5
DB2 V8.1
I have everything installed, and wrote some various test pages to ensure my installation of PHP was correct.
So far I have been able to access my db2 database through PHP and can issue: deletes, updates, inserts, create tables, etc. Pretty much everything except for SELECT statements. As soon as I try to run odbc_exec() against my database with a select statement, the browser appears to "freeze" and nothing happens. When I display ps -ef , I can see wwwrun is added to the list of processes. It just stays there. Every subsequent run of a select statement adds another process. However, with the above mentioned inserts, deletes, etc. this does what it is supposed to do and creates one instance of wwwrun which goes away after a successful run.
Here is the code that I have created to connect to the database and select some simple fields from my table called DYNAMIC:
(connect.php)
<?php function dbconnect($verbose) {
$dbname = "SAMPLE";
$username = "username";
$password = "password";
// odbc_connect returns 0 if the connection attempt fails;
// otherwise it returns a connection ID used by other ODBC functions
$dbconn = odbc_connect($dbname, $username, $password);
if (($verbose == TRUE) && ($dbconn == 0)) {
echo("Connection to database failed.");
$sqlerror = odbc_errormsg($dbconn);
echo($sqlerror);
}
return($dbconn);
}
?>
(select.php)
<html>
<head>
<title>Select data from DYNAMIC table</title>
<h3> Select Data from DYNAMIC table </h3>
</head>
<body bgcolor="white">
<?php
// include the dbconnect() function from connect.php
include_once("connect.php");
$verbose = TRUE;
$dbconn = dbconnect($verbose);
echo "Resource ID is: " . $dbconn;
echo "<br />";
$sql = "SELECT NAME FROM DYNAMIC";
$rs = odbc_exec($dbconn,$sql);
$numCols = odbc_num_fields($rs);
echo "There are " . $numCols . " columns in table DYNAMIC.";
odbc_close($dbconn);
?>
If I comment out the $rs = odbc_exec($dbconn,$sql); line, it connects to the database successfully and displays the resource ID #3.. When I pass this to the odbc_exec function, it just hangs PHP and my browser.
Any ideas would be really appreciated...
Thanks!
-Ryan DeVito