---------CMSClass.php----------------<?phpinclude('./include/contentdb.php');class CMSClass { public $content; /** *Get's the content for a pageid, or sets error *to true with error message passed back as *content. */ function getPageContent( $page, &$error ){ if (isset( $page )){ echo ("calling pageDB->getPageContent<br/>\n"); $content = $pageDB->getPageContent( $page ); echo ("called pageDB->getPageContent<br/>\n"); if ($content == null){ $error = true; return $content; } else { $error = false; return $content; } } } function setPageContent( $page, $content, &$error){ if ( (!isset( $page )) or (!isset( $content ))){ $error=true; return 'Error setPageContent() pageid or content not set'; } else{ $result = $pageDB->setPageContent($page, $content); if ( !$result == 'DB_OK' ){ $error = true; return null; } else{ $error = false; return; } } }}echo ("Creating CMSClass() in file CMSClass.php<br/>\n");$CMS = new CMSClass();?>-------contentdb.php-----------<?phprequire_once( "DB.php" ); //Include for PEAR DB function/*** This class just provides a basic wrapper around the database* @package vsCMS*/class contentdb { //Declare our datasource private $dsn='mysqli://website:zzzzxxxx@localhost/africanorphan'; private $conn; public $connected=false; //Bool are we connected ? public $error; /** *This constructor will try to connect to the dbase */ function __construct(){ echo ("In contentdb constructor<br/>\n"); $this->conn =& DB::connect( $this->dsn ); if (DB::isError( $this->conn )){ $this->connected = false; $this->error="In constructor error connecting to database"; } else{ $this->connected = true; } echo("Leaving contentdb constructor<br/>\n"); } /** *Takes a page identifier and returns the content for *that page */ function getPageContent( $page ){ if (!isset( $page )){ $this->error = "Error a page id was not provided to getPageContent()"; return null; } if ( $this->connected==false ){ return null; } else{ $stmt = 'SELECT content FROM pages WHERE pageid='.$page; $result =& $this->conn->query( $stmt ); if ( DB::isError( $result )){ $this->error = $this->conn->getMessage(); return null; } else{ //Everything seemed to go OK return the content //TODO not sure i can return the data like this yet?? //TODO what happens if no records if ( $result->numRows() == 0 ){ return "vsCMS No Content yet..."; } else{ $rwo = $result->fetchRow(); $content = $row[0]; $result->free(); echo ('About to return'); return $content; } } } } /** *Takes an identifier and content and writes the *content to the database returns null on error *and DB_OK on success. */ function setPageContent( $page, $content ){ if ( !(isset( $page ) and isset( $content ))){ $error = "Error setPageContent called either ". "without a pageid or content"; return null; } if ( $connected == false ){ $error = "Error Not connected to a database"; return null; } else{ if (pageidexist($page)){ //Page id exists so we are doing an update $stmt = 'UPDATE pages SET content='.$content. 'WHERE pageid='.$page; $result =& $conn->query( $stmt ); if ( DB::isError( $result )){ $error = $conn->getMessage(); $result->free(); return null; } else{ $result->free(); return 'DB_OK'; } } else{ //Page id does not exist lets insert it $stmt = 'INSERT INTO pages (pageid, content) '. 'VALUES ('.$page.', '.$content.')'; $result =& $conn->query( $stmt ); if ( DB::isError( $result )){ $error = $conn->getMessage(); $result->free(); return null; } else{ $result->free(); return 'DB_OK'; } } } } /** *Returns boolean true if the page id is already used *and returns false if not. Also returns null on error. */ function pageidexist( $page ){ if ( !isset( $page )){ $error="Error pageidexist() called without page"; return null; } if ( $connected == false ){ $error = "Error Not connected to a database"; return null; } else{ $stmt='SELECT pageid FROM pages WHERE '. 'pageid='.$pageid; $result =& $conn->query( $stmt ); if ( DB::isError( $result )){ $error = $conn->getMessage(); $result->free(); return null; } if ( $result->numRows() > 0 ){ $result->free(); return true; } else{ return false; } } }}//Create pageDB object for use after file has been included.echo ("About to create pageDB in file contentdb.php<br/>\n");$pageDB = new contentdb();//Basic error checkif ( $pageDB->connected == false ){ echo "Error Connecting to Database";}else{ echo ( "pageDB exists fine here?<br/>");}?>The main file where i call the function getPageContent() in CMSclass.php contains the following include( "CMSClass.php" ); //This section of code attempts to fetch the pages content //from the CMS system, by including the CMSClass.php file //at the top of this file we create a CMS object we can acces //via $CMS echo ("About to call CMS->getPageContent<br/>\n"); $myContent = $CMS->getPageContent('index_php', $error); if ( $error == true ){ echo('<div class="error">There were errors:</div>'); } echo $myContent;?>The debug echos iv'e placed throught show as follows.About to create pageDB in file contentdb.phpIn contentdb constructorLeaving contentdb constructorpageDB exists fine here?Creating CMSClass() in file CMSClass.phpAbout to call CMS->getPageContentcalling pageDB->getPageContentNotice: Undefined variable: pageDB in /home/steven/African Orphans/African Orphans/design1/index/CMSClass.php on line 16