|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-09-22 20:18 UTC] larry dot menard at rogers dot com
Description:
------------
(I'm actually using PHP 5.2.0RC5-dev, but it is not listed in the selection box.)
First I had problems getting the ibm_db2 extension to load at all. I had to grant Read and Execute permission to the "IUSR_CS288290-A" account (my host name is CS288290-A) on both the "sqllib\bin" and "sqllib\lib" directories. This should be documented somewhere.
After that I found that even a simple test script does not work when run against an IIS server.
I know that the db2_connect() is truly not successful because a db2trc shows no DB2 server activity at all.
And as you can see, the db2_conn_error() does not seem to pick up the fact that the db2_connect() failed.
It works fine against an Apache server and when run via the command prompt.
I really would like to get ibm_db2 to work with IIS, but there's no documentation anywhere regarding this.
Please advise.
Thanks.
Reproduce code:
---------------
<?php
if (key_exists('SERVER_SOFTWARE', $_SERVER)) $br = "<br>";
else $br = "\n";
$dbname = "mydbname";
$userid = "myuserid";
$password = "mypasswd";
printf("Calling db2_connect()...${br}");
$dbconn = db2_connect($dbname, $username, $password);
printf("Returned from db2_connect().${br}");
printf("\$dbconn = ");
var_dump($dbconn);
printf("${br}");
printf("db2_conn_error() returns: ");
var_dump(db2_conn_error());
printf("${br}");
if (db2_conn_error()) // db2_connect() is apparently failing but this doesn't seem to be returning true
{
printf("Connect failed.${br}");
printf("%s.${br}", db2_conn_errormsg ());
}
else
{
printf("Connect successful.${br}");
db2_close($dbconn);
}
exit;
?>
Expected result:
----------------
Calling db2_connect()...
Returned from db2_connect().
db2_conn_error() returns: string(0) ""
$dbconn = resource(4) of type (DB2 Connection)
Connect successful.
Actual result:
--------------
Calling db2_connect()...
Returned from db2_connect().
$dbconn = bool(false)
db2_conn_error() returns: string(0) ""
Connect successful.
Warning: db2_close() expects parameter 1 to be resource, boolean given in C:\MyServer\testIISDB2.php on line 52
PHP Warning: db2_close() expects parameter 1 to be resource, boolean given in C:\MyServer\testIISDB2.php on line 52
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 07:00:01 2025 UTC |
Hi Larry, I have been trying to resolve this issue for sometime now and I have gotten my IIS setup working now on Win XP/DB2 Express C V9/ibm_db2 1.5.1. The main issue was permission problems with the IIS users created to connect to DB2. It was a matter of adding the IUSER_COMPNAME to the respective database on the DB2 Control Center. Also ensuring that the group they belong to had the connect permissions in the DB2 Control Center. Another important part was ensuring that your connection string had the correct hostname (not localhost but the name of the computer in the DB2 Control Center). Here is my script that I tested with: <?php if (key_exists('SERVER_SOFTWARE', $_SERVER)) $br = "<br>"; else $br = "\n"; printf("Calling db2_connect()...${br}"); $conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=TESTDB;HOSTNAME=MYHOSTNAME;PORT=50000;PROTOCOL=tcpip;UID=myuser;PWD=******;"; $dbconn = db2_connect($conn_string, '', ''); printf("Returned from db2_connect().${br}"); printf("\$dbconn = "); var_dump($dbconn); printf("${br}"); printf("db2_conn_error() returns: "); var_dump(db2_conn_error()); printf("${br}"); if (db2_conn_error()) // db2_connect() is apparently failing but this { printf("Connect failed.${br}"); printf("%s.${br}", db2_conn_errormsg ()); } else { printf("Connect successful.${br}"); db2_close($dbconn); } exit; ?> The results from this script now show: Calling db2_connect()... Returned from db2_connect(). $dbconn = resource(1) of type (DB2 Connection) db2_conn_error() returns: string(0) "" Connect successful. If you do not understand what is needed to get this working or anything else, please feel free to contact me. --Kellen (kfbombar)