Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2001011

Re: [PHP-DB] IBM DB2 and DSN From: Tyson Lloyd Thwaites (tysonlt <email protected>)
Date: 01/02/01

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 <email protected>> wrote in message
news:20001228174353.A1565 <email protected>
> 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>
>

-- 
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>