PHP include_once not working (have tried almost everything I've found)

1.5k Views Asked by At

Context: I am very new to PHP.

My server directory is home/crowdapp/public_html/brand/

In home/crowdapp/public_html/brand/signup.php, I am trying to include two files:

home/crowdapp/public_html/brand/includes/signup.inc.php and home/crowdapp/public_html/brand/includes.config.php

with the include_once() function and require.

Both includes were working fine last week but suddenly they stopped working.

I have tried using __DIR__."file_path", ../filepath, ./filepath, and /filepath.

and even the full link, but nothing is working. I have looked at similar questions and the answers aren't working for me either. How can I fix this?

3

There are 3 best solutions below

0
On

Try this:

include_once __DIR__ . 'includes/signup.inc.php';
0
On

For the first file:

include_once('includes/signup.inc.php');

For the second file:

include_once('includes.config.php');

To display the errors to see what's wrong put the following code at the top of the php file and remove it after debugging:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
1
On

It is possible that your webserver (most likely apache or nginx) can't access directories or files outside of its root directory. Note: The system root directory and the webserver root directory are two different directories. Try including the files with the path relative to your webserver root instead.

If your webserver root is "home/crowdapp/public_html/brand/". To include signup.php, type include_once("/signup.php"); or include_once("signup.php");