Newbie Question (PHP,Postrgresql,Pear)
| From: | bnix | Date: | Tue, 13 Jul 2004 14:41:26 +0000 |
| Subject: | Newbie Question (PHP,Postrgresql,Pear) | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-13698@lists.php.net to get a copy of this message | ||
Hello Everyone,
I am extremely new to PHP,Postgres and Pear, and I am just working on a few
little scripts to get my fee wet, and the code below is not displaying any
errors, which I though it would with the getDebugInfo() any pointers as to
where I should look would be greatly appreciated.
Thanks,
Bruce
<?php
//require_once("C:\Program Files\php\PEAR\DB.php");
require_once 'DB.php';
$user = 'postgres';
$pass = "";
$host = 'localhost';
$db_name = 'db_merrymaids';
$dsn = "pgsql://$user:$pass@$host/$db_name";
$db = DB::connect($dsn);
if (DB::isError($db))
{
die($db->getDebugInfo());
}
// make your query
$query = "select * from tb_addresses";
$res = $db->query($query);
if (DB::isError($res))
{
echo("$query<P>\n");
die ($res->getDebugInfo());
}
// display your results
while ($row = $res->fetchInto()) {
// Assuming DB's default fetchmode is DB_FETCHMODE_ORDERED
echo $row[0] . "\n";
}
// disconnect and return
$db->disconnect();
?>