PDA

View Full Version : Problems installing Pear


Pompiuses
08-17-2003, 03:09 PM
I run php4.3.2 on apache2 on winxp and plan to use Pear that comes bundled with php. I've run go-pear.bat, and the Pear install looks ok. The Pear basedirectory is c:\php\PEAR and include_path=".;c:\php\pear" is added in php.ini.

When I try to exceute the following script:

<?php

// Include the appropriate PEAR classes
// The pear base directory must be in your include_path in php.ini
require_once 'DB.php';
$user = 'myname';
$pass = 'mypass';
$host = 'localhost';
$db_name = 'mydbname';

// Data Source Name: This is the universal connection string
$dsn = "mysql://$user:$pass@$host/$db_name";

// DB::connect will return a Pear DB object on success
// or a Pear DB Error object on error
// You can also set to TRUE the second param
// if you want a persistent connection:
// $db = DB::connect($dsn, true);
$db = DB::connect($dsn); //<-- Gets error here

// With DB::isError you can differentiate between an error or
// a valid connection.
if (DB::isError($db)) {
die ($db->getMessage());
}

// You can disconnect from the database with:
$db->disconnect();
?>

.... I get the errormessage:
Fatal error: Undefined class name 'db' in C:\Program Files\Apache Group\Apache2\htdocs\pear\DB.php on line 20

It seems like the DB class cannot be found. DB.php is located at c:\php\PEAR\DB.php

I don't understand why it doesn't work ..... :confused:

firepages
08-17-2003, 04:22 PM
I don't know the answer to your question though I can say for sure that its not a file not found error , if DB.php could not be found then this line would kill the script ..

require_once 'DB.php';

DB.php also requires PEAR.php , though again it should die at that point with the appropriate message.

try adding
ERROR_REPORTING(E_ALL) ;

at the head of your script and see if that pops up any more useful errors.

Pompiuses
08-17-2003, 04:26 PM
Originally posted by firepages
I don't know the answer to your question though I can say for sure that its not a file not found error , if DB.php could not be found then this line would kill the script ..

require_once 'DB.php';

DB.php also requires PEAR.php , though again it should die at that point with the appropriate message.

try adding
ERROR_REPORTING(E_ALL) ;

at the head of your script and see if that pops up any more useful errors.

Didn't get more errormessages......

Is there any way of testing that the Pear installation is ok?

Pompiuses
08-17-2003, 04:29 PM
When I delete DB.php from the c:\php\pear folder I still get the same errormessage. Strange....

Pompiuses
08-17-2003, 04:47 PM
Ok, found a solution. I had to declare the entire path to the DB.php:

require_once 'c:\php\pear\DB.php';

I have no idea why, because the installation looks fine to me. Any suggestions to what might fix this problem is appreciated.

firepages
08-17-2003, 06:07 PM
Hi , have you restarted your webserver since adding pear to the include path ?

Pompiuses
08-17-2003, 06:56 PM
Originally posted by firepages
Hi , have you restarted your webserver since adding pear to the include path ?

yes, many times.... oh well, god works in mysterious ways :rolleyes: