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 8549507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:43:50+00:00 2026-06-11T13:43:50+00:00

On a page I am building, I require it to load a file into

  • 0

On a page I am building, I require it to load a file into a portion of the page depending on a variable at the end of a URL. For example, if the page URL is test.php?page=lp then the page will include the file lp.php …… now this was working for a while, but all of a sudden has stopped and I am just getting an error returned as though the file isn’t there. I then ‘prettied’ up the script so that if the file “is not found” then a message saying so will be displayed, like this:

<?php $times = substr_count($_SERVER['PHP_SELF'],"/");
$rootaccess = "";
$i = 1;

while ($i < $times) {
 $rootaccess .= "../";
 $i++;
}
$y = date("Y");
$ymo = $y-1;

//$rootaccess.
if(!file_exists($page.".php")){
echo "The file requested (www.websitename.co.uk$rootaccess$page.php) was not found, or an error occured";

}
else {include($rootaccess.$page.".php");} ?>    

And all that happens is the result for if the file is not found is thrown up… so for the example of test.php?page=lp the message is returned “The file requested (www.websitename.co.uk/lp.php) was not found, or an error occured”. But here’s the thing, the file IS THERE, because the page also uses AJAX, and if I use the AJAX link to load up the exact same file at the exact same location, it works! (likewise if I enter the address show in the error, it works) I have used GET in order for the script to ascertain if $page has been set, as this changes other elements of the page too, so I know this is working… but yet for some reason it no longer wants to include the file – so what is the workaround for this? (I have tried it without the rootaccess bit as well, and it still fails)
Thanks.
(also, if anybody has any sort of idea as to why include($rootaccess.$page.”.php”) would work one day and then stop working the next then I’d love to know because at the moment I am just shouting at the page for it to work!!!)

  • 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-11T13:43:52+00:00Added an answer on June 11, 2026 at 1:43 pm

    I think I have been stumbled the same issue before. Try to use:

    $foo = trim($page.".php");
    
    if(!file_exists($foo)) {
         :
    } else {
         include(trim($rootaccess.$foo));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to PHP, and building a page that displays a customer order form
I'm currently building a web page which require to call some system apis such
Am building a single page site with backbone.js. Am using require.js to make the
I am building a simple rails app and when I load the home page
I'm building a page which loads the contents of our MySQL db for editing.
The page I'm building depends heavily on AJAX. Basically, there is just one page
I am building a page using blocks of sections: http://jsfiddle.net/NrkTn/3/ You can see I
Good day everyone, I am building a page in ASP.NET, and using Master Pages
Okay, I'm building a page in a CF environment. I'm testing in chrome/FF &
I am building my own home page. I find someone's page good, and downloaded

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.