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.42 KB

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

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


Regards,
ivanceras

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

I am also struck with same kind of issue. If some one found a solution please revert me also, thanks in advance.

Edited 2 Years Ago by pritaeas: Removed email. Keep it on-site.

Try switching the PHP version. AMPPS Control Center -> PHP Tab -> Change PHP version.

This article has been dead for over six months. Start a new discussion instead.