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:
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: