I need some help with my setup. My system is as follows:
XP Professional
DB2 UDB EE 7.2
Apache 1.3.24
PHP 4.2.3
The problem is that when following these instructions for learning how to connect( http://www7b.software.ibm.com/dmdd/library/techarticle/scott/0614_scott.html ), which for the most part seem informative. The problem that I am having is that PHP is not recognizing my DB2 database that is on the same server.
for example:
<?php function dbconnect($verbose) {
$dbname = "uptt";
$username = "db2admin";
$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);
}
?>
followed by:
<?php
// include the dbconnect() function
include_once("db2lib.php");
$author_insert = "INSERT INTO uptt_users(fname, priv_level, password, email) VALUES('Bob Analyst', 'BA', 'password','banalyst@uptt.com')";
$verbose = TRUE;
$dbconn = dbconnect($verbose);
if ($dbconn != 0) {
// odbc_exec returns 0 if the statement fails; otherwise
// it returns a result set ID
$result = odbc_exec($dbconn, $author_insert);
if ($result == 0) {
echo("INSERT statement failed.");
$sqlerror = odbc_errormsg($dbconn);
echo($sqlerror);
}
else {
echo("Successfully inserted one row.");
}
}
?>
When I step through with Kimodo I can see that the connection is not being made. I thought I would use pear but that was no good either. I can use similar code to access MySql just fine.