0

I'm building a simple web applicationg using PHP. (It's a CV-like web application)

In the project folder, I have sub folders for my styling, includes such as header/footere and database files. The problem I am facing is the following:

I'm using relative paths to get my web application to work. That's fine until I go into a web page that is within a sub-folder, and is trying ti include the header from a different sub-folder. It throws the error that the file does not exist. Everything is working perfectly until I go to a webpage that is located in a sub-folder, and when I load the header, it's giving me an error that theere is no such file (file that connects to the DB through the header file).

I know this sounds confusing, but if I thought it'll be more confusing if I just uploaded codes of my whole project so I tried explaining it this way.

After doing some research, I found out that it is quite common to face this issue by using relative paths.

My question is, is it possible for me to have an external php document, where I store paths in a variable of essential files such as my database connection etc., and call it that way to avoid confusion and errors?

Also, is it possible to start every path from the project's root by default and not by using relative paths?

I have not tried anything as I am really confused.

  • 1
    Please post the URL of the webpage with the broken links, and post the generated source of one of the broken links. We have no information to work on in your question. – Jacob Mulquin Jun 07 '23 at 03:16
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jun 07 '23 at 06:04
  • https://phpdelusions.net/articles/paths might also be able to offer some helpful insights. – CBroe Jun 07 '23 at 06:39

0 Answers0