0

I want to Create an beginners php oop script with an shop database.

Until i have create a Category Class, a main.php script and a dbCon.php Script. The main script includes the database connection and should create some category classes with the pdo fetch class statement -> so the plan...

No comes my problem: the main.php cant find the category class and my script stops with an fatal error:

Fatal error: Class 'Core\Category' not found in C:\xampp\htdocs\main.php on line 10

Here is my main.php

<?php
    namespace Core;
    use PDO;

    include "dbCon.php";

    $stmt = $pdo->query("SELECT id FROM s_categories");
    $res = $stmt->fetchAll(PDO::FETCH_CLASS,"Core\\Category");
?>

and here my category class:

class Category
{
    private $cid;
    private $cmsText;
    private $aid = [];
    private $id;
}

since both files are in the same namespace the main.php should find the category class, right?

treyBake
  • 6,440
  • 6
  • 26
  • 57
NETFLOX
  • 119
  • 1
  • 10

0 Answers0