Re: [PHP-DB] IBM DB2 and DSN From: Yasuhide OMORI (omori <email protected>)
Date: 12/28/00

On Thu, Dec 28, 2000 at 11:36:16AM +1030,
Tyson Lloyd Thwaites <tysonlt <email protected>> 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

-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>