DB Error in PEAR

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
amlan_08
Forum Newbie
Posts: 11
Joined: Sun May 22, 2005 1:24 am

DB Error in PEAR

Post 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
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post 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.
Post Reply