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

  • Home
  • SEARCH
  • 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 8770955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:39:58+00:00 2026-06-13T17:39:58+00:00

This is my ‘index.php’ file (part of it): <?php // Require every .php file

  • 0

This is my ‘index.php’ file (part of it):

<?php

// Require every .php file inside "phpClasses" folder
foreach (glob("phpScripts/*.php") as $filename) {
require_once $filename;
}

// Create the $db object
$db = Database::obtain(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); 

// Connect to the database
$db->connect();

// Instantiate the "language" and "databaseQuery" classes
$lang = new language();     
$dbQuery = new databaseQuery();     

// Detect if the laguage has changed from the user and apply the new "current language"
if(isset($_GET["change_lang"])) {
    $change_lang = $_GET["change_lang"];
    $cur_lang = $change_lang;
} else {
    $cur_lang = $lang->getCurLang();
}
?>
<head>
...
</head>
<body>        
    <div id="cur_content" class="temp_content" data-tempPos="0">
    <?php 
        include 'pages/home.php'; 
    ?>
    </div>  <!-- #cur_content -->
</body>

Inside #cur_content I inject ‘blog.php’ via ajax call:

‘blog.php’:

<div id="blog_main_content" class="temp_content">
    <?php
        include "blog_list.php";
    ?>
</div>

..and inside it, I include ‘blog_list.php’:

foreach (glob("phpScripts/*.php") as $filename) {
    require_once $filename;
}

// Create the $db object
$db = Database::obtain(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); 

// Connect to the database
$db->connect();

$dbQuery = new databaseQuery();     

// Get the language from loader.php
$cur_lang = "'".$_SESSION['language']."'";

$dbQuery->getArticleList($cur_lang);

 ?>

Inside #blog_main_content div, I inject ‘articleLoader.php’ via ajax call and works fine.
‘blog_list.php’ is displayed just fine for the first time.
When user returns to ‘blog_list.php’ via ajax call, I get the following error:

Fatal error: Class ‘Database’ not found in C:\wamp\www\kapantzakis_2.14\pages\blog_list.php on line 8

I think that php does not execute the require_once in ‘blg_list.php’ when ajax calls this file.

I don’t know if I explain well.

Thanks for any help!

edit#1

Ajax call:

// Perform the ajax call
        function getAjaxPage(method, content, currentOffset) {

            var temp_content = $('.temp_content');                      
                var temp_content_last = temp_content.filter(':last');

            var blog_main_content = $('#blog_main_content');                    
                var blog_main_content_first = blog_main_content.filter(':first');

                // Insert the html data in to the first or last div depending on the movement of the page
                if (method == 'next') {
                    var insert_div = temp_content_last;
                } else if (method == 'prev') {
                    var insert_div = blog_main_content_first;
                }

                // Get article or the article list
                if (content == 'article') {
                    var page = 'articleLoader.php';
                } else if (content == 'article_list') {
                    var page = 'pages/blog_list.php';                       
                }
                /*
                var lang = getCurLang();
                var data = 'lang=' + lang + '&art_id=' + art_id;*/

                var tags_wrapper = $('#tags_wrapper');

            $.ajax({
                url: page,  
                type: "GET",    
                /*data: data,*/
                cache: false,
                success: function (html) {                          
                    insert_div.html(html)
                        .queue(function() {
                            var return_to_list = $('#return_to_list');                              
                            return_to_list.attr('data-offsetTop', currentOffset);   
                            returnTopOffset();
                            if (content == 'article') {
                                tags_wrapper.fadeIn(800);
                            } else if (content == 'article_list') {
                                tags_wrapper.hide();
                            }                               
                            $(this).dequeue();
                        });
                }       
            });
            return $(this);
        }
  • 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-06-13T17:40:00+00:00Added an answer on June 13, 2026 at 5:40 pm

    I assume your folder structure looks like this:

    kapantzakis_2.14/
      articleLoader.php
      blog.php
      blog_list.php
      index.php
      pages/
        home.php
      phpScripts/
        Database.php
    

    Your AJAX-Call requests pages/blog_list.php directly, but in your question-text it seems like blog_list.php is located in your root directory (kapantzakis_2.14).

    The error you get ([…]'Database' not found in C:\wamp\www\kapantzakis_2.14\pages\blog_list.php[…]) shows the blog_list.php is located in the pages-folder instead. Your glob-call cannot find a directory called phpScripts in the pages-Folder, so the required_once calls never get executed.

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

Sidebar

Related Questions

This is the file auth.txt (username password) paolo 1234 luca 0000 marci 1000 And
This is my first time creating a PHP form that will run a MySQL
This is what i tried . In my view.py file , import logging logger
This questions is more to do with the mechanics of PHP versus the intricacies
This problem is intermittent, occurring every few hours on a process that runs every
this is my first question in here, and I would like to ask if
This question is directly related to this SO question I posed about 15 minutes
This question is kind of a follow up to this question I asked a
This should be a simple one: I have an observableArray object called To in
This sequence satisfies a(n+2) = 2 a(n+1) + 2 a(n). and also a(n)=[(1+sqrt(3))^(n+2)-(1-sqrt(3))^(n+2)]/(4sqrt(3)). I

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.