I am having a problem when Configuring PHP to work with DB2 on Windows 7 Professional.
I followed the instructions at: http://techsatwork.com/blog/?p=145. When I enter http://localhost:85/ I get the BitNami Project welcome page but when I edit the sample code php application that access DB2 and go to url: http://localhost:85/phpexp.php, I get: This error (HTTP 500 Internal Server Error) means that the website you are visiting had a server problem which prevented the webpage from displaying.
The error.log shows: [Wed Sep 21 12:49:13 2011] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined function db2_connect() in K:\\Program Files\\BitNami WAMPStack\\apache2\\htdocs\\phpexp.php on line 7.
here is the code:
<?php
$database = 'SAMPLE';
$user = 'db2admin';
$password = '*****password***';
$hostname = 'localhost';
$port = 50000;
$connection = db2_connect($database, $user, $password);
if ($connection)
{
echo "Connection succeeded."."\n";
}
else
{
echo "Connection failed.<br />";
echo 'SQLSTATE : ' . db2_conn_error() . '<br/>';
echo 'Message : ' .db2_conn_errormsg(). '<br />';
}
$sql = 'select CREATOR,NAME from sysibm.systables where type = ?';
echo $sql;
$stmt= db2_prepare($connection, $sql);
if (!$stmt)
{
echo 'The prepare failed. ';
echo 'SQLSTATE : '. db2_stmt_error() ;
echo 'Message : '. db2_stmt_errormsg();
}
else
{
db2_bind_param($stmt, 1, "type", DB2_PARAM_IN);
$type = T;
$result = db2_execute($stmt);
if (!result)
{
echo 'The execute failed .';
echo 'SQLSTATE : '. db2_stmt_error() ;
echo 'Message : '. db2_stmt_errormsg();
}
else
echo '<table align ="center" cellspacing="5" cellpadding="1"
<tr><td align="left"><b>Creator</b></td>
<td align="left"><b>Name</b></td></tr>';
}
while ($row = db2_fetch_array($stmt))
{
echo "<tr><td align=\"left\">$row[0]</td><td align=\"left\">$row[1]</td></tr>\n";
}
echo '</table>';
?>
DB2 installed at: K:\DB2_01\NODE0000\SAMPLE
K:\Program Files\IBM\SQLLIB_01
Can anyone tell me why it will not connect?
James
James R. Martin
J. Martin Associates
5185 Tara Ln., Bossier City, LA 71111 - 7810
Phone: (318) 752-4109 Cell Phone: ( 318) 773-9484
Personal e-mail: jmartin@jmartinassociates.net
Configuring PHP to work with DB2 on Windows 7 Professional
Moderator: General Moderators