主要有以下四种方法:
1、用adodb联结:
<?php
Session_Start();
$user=$_POST["user"];
$pwd=$_POST["pwd"];
if(isset($user)) {
$_SESSION["user"]=$user;
$_SESSION["pwd"]=$pwd;};
session_write_close ();
error_reporting(0);
include_once('/usr/share/php/adodb/adodb-errorhandler.inc.php');
include_once('/usr/share/php/adodb/adodb.inc.php');
$db =&ADONewConnection('postgres'); # eg 'mysql' or 'postgres'
// $db->debug = true;
$host='xxx.xxxx.xxx';
$port='5432';
$dbname='test';
$user=$_SESSION["user"];
$password=$_SESSION["pwd"];
$conn_string = "host=$host dbname=$dbname user=$user password=$password port=$port";
$db->Connect($conn_string) or die("can't connect!");
?>

2、直接联结:
<?php
//dl('pgsql.so');
Session_Start();
$user=$_POST["user"];
$pwd=$_POST["pwd"];
if(isset($user)) {
$_SESSION["user"]=$user;
$_SESSION["pwd"]=$pwd;};
session_write_close ();
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';

$host='xxxx.xxxx.xxxx';
$port='5432';
$dbname='test';
$conn_string = "host=$host dbname=$dbname user=$user password=$password port=$port";
$dbconn = pg_connect($conn_string) or die("Could not connect");
if ($dbconn){echo 'ok';}else{echo 'fales';};
print_r(pg_version());

$query='select * from bzzl';
$rs=pg_query($dbconn,$query);
$fd=pg_fetch_assoc($rs);

echo "\n";
$myfd=$fd['dw'];
echo $myfd;

pg_close($dbconn);
?>
内文分页: [1] [2]
Tags: , , , , , ,

Written on 2007/04/25 by Doctor - Reads: 2187 Comments: 0

发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
昵称   密码   游客无需密码
网址   电邮   [注册]
               

验证码 不区分大小写