undefined class name 'db' help sought


#1

Sorry if this has been posted (and resolved) before but I’ve been banging at this for HOURS and no joy…

I’m running Apache2 under WindowsXP with PHP4.3.8.
and keep getting this error when trying to use any DB PEAR calls.

phpinfo() confirms PHP install OK and can use other PEAR packages so what gives?

any help MUCH appreciated!


#2

DId you include the DB class?

require_once( “DB.php” );


#3

yups…sorry, code below. any ideas?

[php]

<?php include('dbinfo.php'); require_once 'DB/DB.php'; $db =& DB::connect( "mysql://$dbuser:$dbpass@$dbhost/$dbname" ); if (DB::isError($db)) { die($db->getMessage()); } $sql = 'SELECT * FROM demo'; $demoResult = $db->query($sql); if ( DB::isError( $demoResult = $db->query( $sql ) ) ) { echo DB::errorMessage($demoResult); } else { while ($demoRow = $demoResult->fetchRow()) { echo $demoRow[2] . '
'; } } $db->disconnect(); ?>[/php]

#4

sorry, correct require_once reads…

[php]

<?php include('dbinfo.php'); require_once 'DB.php'; $db =& DB::connect( "mysql://$dbuser:$dbpass@$dbhost/$dbname" ); if (DB::isError($db)) { die($db->getMessage()); } $sql = 'SELECT * FROM demo'; $demoResult = $db->query($sql); if ( DB::isError( $demoResult = $db->query( $sql ) ) ) { echo DB::errorMessage($demoResult); } else { while ($demoRow = $demoResult->fetchRow()) { echo $demoRow[2] . '
'; } } $db->disconnect(); ?>

[/php]

s’cuse the botched post. New to this forum gubbins :wink:


#5

SORTED!
Just changed require_once to point to ‘…/pear/db.php’ and it works!
Thanks for your reply :D