I want to use the pear package.Pear is already on my xampp package.On the file php.ini the pear is included(I didn't change the file php.ini..there is a line like include_path = ".;c\xampp\php\PEAR").I used the following code to retrieve the results from database..But it is not working ..

// Include the appropriate PEAR classes

$dsn = array(
 'phptype'  => 'mysql',
 'hostspec' => 'localhost',
 'database' => 'emp',
 'username' => 'root',
 'password' => 'mysql'
$dbh = DB::connect($dsn);

$stmt = "SELECT id, name FROM examples ORDER BY id";
$result = $dbh->simpleQuery($stmt, DB_FETCHMODE_ASSOC);
if ($dbh->numRows($result) > 0) {
 $data = (object) $dbh->fetchRow($result, DB_FETCHMODE_ASSOC);
 echo "id   => $data->id<br>\n";
 echo "name => $data->name<br>\n";


showing the errors like following ...

Warning: require_once(DB.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\divya\Pear-examples\dbconnect.php on line 3

Fatal error: require_once() [function.require]: Failed opening required 'DB.php' (include_path='.;c\xampp\php\PEAR') in C:\xampp\htdocs\divya\Pear-examples\dbconnect.php on line 3

include_path = ".;c\xampp\php\PEAR"

Anybody knows plz help me to solve this...


Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

6 Years
Discussion Span
Last Post by divyakrishnan

Tried taking off the ';' before the statement?

;include_path = ".:/php/includes"


include_path = ".:/php/includes"

Edited by diafol: n/a


Well, you've probably got a few php.ini files in the installation - try doing the same to all of them. I always get confused as to why there are so many of them.


First, leave the php.ini files alone. The semicolon in the include path is correct for Windows (note the C:\ drive reference in the original post). The real problem is a missing pear/DB installation. The pear/DB is deprecated in favor of pear/MDB2, so you're experiencing a growth issue.

execute the following in the php installation directory:

pear install DB

...and viola - now you have an entirely new problem. Happy hunting...


Thank you very much Mr DC Buller................Now Its working..................You are kidduuuuuu....


i m facin the similar problem... and i am new to this stuff... can anyone let me knw how to install install db... thanks

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.