[PHP] Re: [PHP-DB] Connect to IBM DB2

2002-01-02 Thread Frank M. Kromann

Hi,

IBM DB/2 uses Call Level Interface (CLI) for communication between clients and server. 
The ODBC driver from IBM is a simple one to one wrapper arround CLI, as CLI and ODBC 
share the same specifications.

Using ODBC will give you an extra layer though. On *nix platforms you can compile usen 
--with-ibm-db2 and get the ODBC functions linked directly with CLI. This is not 
currently available on Windows.

- Frank

 To connect to Microsoft SQL 7 I'm using the following script which works
 fine:
 
 ?php
 $query=SELECT * FROM DB1;
 $queryupd=UPDATE DB1 SET dateval='20010101' where dateval='2101';
 $hostname = dbserver;
 $username = username;
 $password = pwd;
 $dbName = DB;
 mssql_connect($hostname,$username,$password) or die(DATABASE FAILED TO
 RESPOND.);
 mssql_select_db($dbName) or DIE(Table unavailable);
 $result2 = MSSQL_QUERY($queryupd); // Execute Update Statment
 $result = MSSQL_QUERY($query);  // Execute Select Statment
 $number = MSSQL_NUM_ROWS($result);
 $i=0;
  if($number == 0) print No data?;
  elseif($number  0){
  print Number of rows: $numberBR;
 while($i  $number){
  $dateval = mssql_result($result,$i,dateval);
 echo TRTDFONT color=#112266$dateval/FONT/TD;
  $i++;}
 }
 ?
 
 Now, how to connect to a DB2 database server without ODBC ?
 
 My config is:
 Web Server: IIS on windows 2000 Server
 Database Server: IBM DB2 V7.1 on windows 2000 Server
 PHP4 for windows
 
 Thanks.
 
 Jerry
 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] db connect

2001-11-29 Thread Ian

Hello,

Wonder if anyone can help me out.

I am trying to run an example out of a book Beginning Php by wrox.

One of the examples is supposed to allow me to connect to a database by
using a function that takes a database as an argument. It has an include
file that contains the function.

Problem I get is that the argument never seems to get passed and the
function always uses the default value.

I would greatly appreciate if someone could tell me why this happens. I
would also appreciate if no one rewrites a completely different script, as I
am after debugging this one. ;-)

Here is the include file:

?php
//common_db.inc
$dbhost = 'localhost';
$dbusername = 'phpuser';
$dbuserpassword = 'phppass';
$default_dbname = 'mysql';

$MYSQL_ERRNO = '';
$MYSQL_ERROR = '';

function db_connect($dbname=' ') {
   global $dbhost, $dbusername, $dbuserpassword, $default_dbname;
   global $MYSQL_ERRNO, $MYSQL_ERROR;

   $link_id = mysql_connect($dbhost, $dbusername, $dbuserpassword);
   if(!$link_id) {
  $MYSQL_ERRNO = 0;
  $MYSQL_ERROR = Connection failed to the host $dbhost.;
  return 0;
   }
   else if(empty($dbname)  !mysql_select_db($default_dbname)) {
  $MYSQL_ERRNO = mysql_errno();
  $MYSQL_ERROR = mysql_error();
  return 0;
   }
   else if(!empty($dbname)  !mysql_select_db($dbname)) {
  $MYSQL_ERRNO = mysql_errno();
  $MYSQL_ERROR = mysql_error();
  return 0;
   }
   else return $link_id;
}

function sql_error() {
   global $MYSQL_ERRNO, $MYSQL_ERROR;

   if(empty($MYSQL_ERROR)) {
  $MYSQL_ERRNO = mysql_errno();
  $MYSQL_ERROR = mysql_error();
   }
   return $MYSQL_ERRNO: $MYSQL_ERROR;
}
?

And here is the php script that uses this include file:


?php
//show_more_db.php
include ./common_db.inc;

$link_id = db_connect('sample_db');
$result = mysql_query(SELECT * FROM user, $link_id);

while($query_data = mysql_fetch_row($result)) {
?
 ?php
echo ',$query_data[1],' is also php ' known as ,$query_data[3],P;
}
?


I hope someone can help me out please.

Thankyou.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]