Re: IBM DB2 and DSN

From: Date: Wed, 03 Jan 2001 00:27:49 +0000
Subject: Re: IBM DB2 and DSN
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-5539@lists.php.net to get a copy of this message
You don't need to build a windows-style DSN string in this case. Just use the name of the database you want to connect to as the dsn, for example, to connect to the sample db: $con = odbc_pconnect("sample", "db2inst1", "ibmdb2"); This is assuming you are connecting using PHP with DB2 support compiled in. In regards to apache dying, I had this problem too. You have to get the apache source and build PHP using --with-apache instead of --with-apxs. Then DB2 support works fine! Regards, Tyson Lloyd Thwaites I.T&e eCommerce Division Adelaide www.ite.com.au "Yasuhide OMORI" <omori@m-t.com> wrote in message news:20001228174353.A1565@omori.m-t.com... > 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 > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.db (#5539) next »