Re: IBM DB2 and DSN
| From: | Yasuhide OMORI | Date: | Thu, 28 Dec 2000 08:43:54 +0000 |
| Subject: | Re: IBM DB2 and DSN | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-5480@lists.php.net to get a copy of this message | ||
On Thu, Dec 28, 2000 at 11:36:16AM +1030,
Tyson Lloyd Thwaites <tysonlt@webmedia.com.au> wrote:
> Can you please show us your code?
my code is as follows:
-8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<-
-8<- -8<-
<?php
//header("Content-Type: text/html; charset=euc-jp");
//phpinfo();
//$dsn="DRIVER=IBMdb2;SERVER=192.168.1.16;DATABASE=sample";
$dsn="host=192.168.1.16";
//$dsn="DSN=CENTER";
//$dsn="DSN=dbalias3";
//printf("LANG: %s<BR>\n", getenv("LANG"));
//putenv("LANG=ja_JP.eucJP");
putenv("LANG=C");
putenv("LC_ALL=C");
putenv("LC_CTYPE=C");
$con1 = odbc_connect($dsn,"db2inst1","ibmdb2"); /* Connection object */
?>
-8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<-
-8<- -8<-
I run this php script from the client machine.
On the other hand if I run the following perl script at the server it
works well:
-8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<-
-8<- -8<-
#!/usr/bin/perl
use strict;
use DBI;
#my $hostname = "192.168.1.16";
my $db_name = "sample";
my $username = "db2inst1";
my $password = "ibmdb2";
#my $dbh = DBI->connect("dbi:DB2:" . $db_name . ":host=".$hostname
# , $username, $password);
my $dbh = DBI->connect("dbi:DB2:" . $db_name
, $username, $password);
my $query = "SELECT * FROM EMPLOYEE";
#printf("%s\n",$query);
my $sth = $dbh->prepare($query) or die();
$sth->execute() or die();
while(my $ref = $sth->fetchrow_hashref()) {
foreach (keys %$ref) {
printf("%s: %s\n",$_,$$ref{$_});
}
print "\n";
}
-8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<-
-8<- -8<-
I tried to build php(DSO version) on the server but httpd is always
killed by SIGTERM whenever I start apache...
--
Yasuhide OMORI