954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Fatal Error Class not found, help

Hi, i am working through Christian Daries PHP and Mysql Ecommerce chapter 4 and am receiving a Fatal Error.

Fatal error: Class 'Catalog' not found in C:\xampp\htdocs\myshop\presentation\departments_list.php on line 23

Can anyone please help me with this error?

Many thanks in advance.

Here is the code from the files associated and i have attached my file structure also.

index:

<?php
// include utility files
require_once 'include/config.php';

// load the application page template
require_once PRESENTATION_DIR . 'application.php';

// load Smarty template file
$application = new Application();

// display the page
$application->display('store_front.tpl');

//load database handler script
require_once BUSINESS_DIR . 'database_handler.php';

//load business teir
require_once BUSINESS_DIR . 'catalog.php';

?>


department_list.php:

<?php
// Manages the departments list
class DepartmentsList
{
  /* Public variables available in departments_list.tpl Smarty template */
  public $mSelectedDepartment = 0;
  public $mDepartments;

  // Constructor reads query string parameter
  public function __construct()
  {
    /* If DepartmentId exists in the query string, we're visiting a
       department */
    if (isset ($_GET['DepartmentId']))
      $this->mSelectedDepartment = (int)$_GET['DepartmentId'];
  }

  /* Calls business tier method to read departments list and create
     their links */
  public function init()
  {
    // Get the list of departments from the business tier
    $this->mDepartments = Catalog::GetDepartments();

    // Create the department links
    for ($i = 0; $i < count($this->mDepartments); $i++)
      $this->mDepartments[$i]['link_to_department'] =
        Link::ToDepartment($this->mDepartments[$i]['department_id']);
  }
}
?>


Catalog:

<?php
// Business tier class for reading product catalog information

class Catalog
{
  // Retrieves all departments
  public static function GetDepartments()
  {
    // Build SQL query
    $sql = 'CALL catalog_get_departments_list()';

    // Execute the query and return the results
    return DatabaseHandler::GetAll($sql);
  }
}
?>
Attachments filestructure.jpg 67.42KB
gdp
Newbie Poster
9 posts since Jan 2007
Reputation Points: 10
Solved Threads: 0
 

The catalog file is not included at the time of the call. Make sure it is.

pritaeas
Posting Expert
Moderator
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 
The catalog file is not included at the time of the call. Make sure it is.


Thankyou for your reply.

Sorry about being dumb,

but how would i do this as i thought it was being called when index.php runs at:

require_once BUSINESS_DIR . 'catalog.php';

many thanks

g

gdp
Newbie Poster
9 posts since Jan 2007
Reputation Points: 10
Solved Threads: 0
 

try inserting the inclusion in department_list.php:
<?php
include_once('catalog.php');
// Manages the departments list
class DepartmentsList
{


Regards,
ivanceras

ivanCeras
Newbie Poster
20 posts since May 2006
Reputation Points: 10
Solved Threads: 1
 

Hello I am having a similar error:
PHP Fatal error: Class 'SB_Modules_Configuration' not found in C:\inetpub\wwwroot\public_html\include\SB\Modules\Settings.php on line 33
although the file Settings.php does exist in that diretory. Can someone help pls? Thanks

Nivilot
Newbie Poster
1 post since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You