Page 1 of 1

DB Error in PEAR

Posted: Mon Jan 02, 2006 5:05 am
by amlan_08
Happy new year to all of you.

I am new in PEAR. I installed it succesfully with DB & Mail Packages.

Now I write the following code to connect my mySQL database and run a simple query

[syntax=php]<?php

require_once("DB.php");
$db_user= "root";
$db_pass= "";
$db_host= "localhost";
$db_name= "xyz";
$dsn= "mysql://$db_user:$db_pass@$db_host/$db_name";
$db= DB::connect($dsn);
if(DB::isError($db))
{
die($db->getMessage());
}
else
{
$joke = $db->query("SELECT * FROM tbl_name");
while($row = $joke->fetch_row())
{
$arr[] = array('title' => $row['name']);
}
print_r($arr);
}
?>[/syntax]

When try run this code it is showing the following error

"[b]DB Error: not found[/b]"

I have no clue of this error. Please help me to run my first PEAR code successfully.

Thanks in advance

Posted: Mon Jan 02, 2006 9:44 am
by BDKR
Well, I certainly suspect it's an error having to do with either the DB or the pear objects themselves. Turn your error reporting all the way up for starters. error_reporting(E_ALL) should do it. You may want to check the documentation for the error object as well. It's been sometime since I've worked with it.