undefined class name 'db' help sought

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!

DId you include the DB class?

require_once( “DB.php” );

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]

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:

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

Sponsor our Newsletter | Privacy Policy | Terms of Service