Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 299645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:50:30+00:00 2026-05-12T06:50:30+00:00

I solved this question my own. The filename was wrong lolz. Hello everyone! I’m

  • 0

I solved this question my own. The filename was wrong lolz.

Hello everyone!

I’m building a CMS like Drupal and Joomla. I’m working on the module feature (plugins), and I got the following error:

Fatal error: Class 'settings' not found in C:\wamp\www\SYSTEM\view.php on line 22

Here is my code:

start.php

<?php
//First of all, start with some advertisement
header("X-Powered-By:ZOMFG CMS, and ofcourse PHP, but that's less important");
//Then less impotant stuff lololol.
session_start();                                //Start a session
mysql_connect($db_host, $db_user, $db_pass);    //Connect to database
mysql_select_db($db_name);                      //Select a database

//Load core
require_once("core.php");

//Load modules
$res_modules = mysql_query("SELECT * FROM ".$_SERVER["db_prefix"]."modules WHERE enabled=1");
echo mysql_error();
$module_exists = array();
while($row_modules = mysql_fetch_array($res_modules))
{
    //Load module
    $name = $row_modules["name"];
    modules::load_module($name);
    //and initialize it
    eval($name."::init();");
    //Yes, it exists
    $module_exists[$name] = true;
}

//Check if the user wants shit from a module
if(isset($_GET["m"]))//Yes the user want it
{
    //Does the module exist and activated, and has it a function called view?
    if(isset($module_exists[$_GET["m"]]) && method_exists($_GET["m"], "view"))//Yep
    {
        //Load view (should be an array)
        eval("\$module_view = ".$_GET["m"]."::view();");
        if(!is_array($module_view))//Not an array :(
        {
            error::e500module($_GET["m"], $_SERVER["REQUEST_URI"]);
        }
        else//The error would kill the entire script, m'kay
        {
            view::index();
        }
    }
    else//Nope, so display error
    {
        error::e404($_SERVER['REQUEST_URI']);
    }
}

settings.php

<?php
class settings
{
    function get($what)
    {
        $result_get = mysql_query("SELECT value FROM ".$_SERVER["db_prefix"]."settings WHERE key='$what'");
        if(mysql_num_rows($result_get) > 0)
        {
            $row_get = mysql_fetch_array($result_get);
            return $result_get["value"];
        }
        else
        {
            return -1;
        }
    }
}

core.php

<?php
//Load core classes
require_once("settings.php");
require_once("error.php");
require_once("theme.php");
require_once("view.php");
require_once("modules.php");

view.php

<?php
class view
{
    function head()
    {
        include("../THEMES/".settings::get("theme")."/head.php");
    }
    function foot()
    {
        include("../THEMES/".settings::get("theme")."/foot.php");
    }
    function left()
    {
        include("../THEMES/".settings::get("theme")."/left.php");
    }
    function right()
    {
        include("../THEMES/".settings::get("theme")."/right.php");
    }
    function index()
    {
        include("../THEMES/".settings::get("theme")."/index.php");
    }
}

Start.php is obviously executed first. Not other pages are executed before it, except customsettings.php that contains database information. If I used $_SERVER[“db_prefix”] in my code above, it’s because I needed a superglobal which is set in customsettings.php:

customsettings.php

<?php
$db_host = "localhost";         //Database host
$db_user = "root";              //Database user
$db_pass = "you may not know this";         //Database password
$db_name = "zomfg";             //Database name
$_SERVER["db_prefix"] = "zomfg_";//Prefix, needs to be superglobal

Can anybody help me? It seems that view.php’s index function is called before settings.php is included. Sorry if this question is huge, I just want to be clear. Also don’t say eval() is evil, I know.

So I want to know why the settings class could not be found. If you need more source code, please comment to this question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:50:30+00:00Added an answer on May 12, 2026 at 6:50 am

    Though you would expect settings.php to be available to view.php because it was included in a script that includes them both, I have found that this usually isn’t the case. You have a couple of choices:

    • require_once all the files each class needs in each class file
    • write an __autoload() function so that PHP can find all your classes whenever it thinks it needs one

    The 2nd option is more flexible.

    If you want to know classes are available from a particular place try outputting get_declared_classes()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may seem like an odd question, but I have my own reasons for
EDIT: This question is solved, but I can't accept my own answer just yet.
The responses I've got to this question have solved the problem I had in
I'm betting that someone has already solved this and maybe I'm using the wrong
Update: This question has been solved, so the buggy Firefox behavior will no longer
Reading this question I found this as (note the quotation marks) code to solve
Ok this is a general question about how to solve this issue, not to
I've actually solved this, but I'm posting it for posterity. I ran into a
Edit: I have solved this by myself. See my answer below I have set
This problem has been solved thanks to your suggestions. See the bottom for details.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.