tags:

views:

187

answers:

3

Hi all

I'm working on a site here where I include parts of the site that are called in multiple locations in it's own sub directory. I created a file in said directory and tried to include it in a file, but for some reason tis' not working. Here's the code that is within that file.

<?php

require_once("a_file.php"); //this file loads
require_once("another_file.php"); //so does this one
require_once("problem_file.php"); //this one does not.

echo foo('I exist');

?>

and the code for the file not being found.

<?php

function foo($string) {
if ($string) {
    return $string;
    }
}

?>

The spelling for the file has been verified to be correct in both the file with the require and the file being called. The include path in the .htaccess file is correct (otherwise none of the required files would load without the full path being specified. The error message is "failed to open stream: No such file or directory". All permissions are the same for the files in the include directory.

Has anyone else ran into this issue?

+1  A: 

Do you have any error in the error_log? It could be that the third file has some more require_once that are not found.

You could try using $_SERVER['DOCUMENT_ROOT'] to get your root directory and use it for your requires.

Eric Hogue
That could have helped to show that yes. Original post updated. Using $_SERVER['DOCUMENT_ROOT'] would work, but it doesn't' explain why the other two preceding it work as intended, which is the mystery. If it was an issue with the htaccess include path, all should be failing?
canadiancreed
A: 

A quick way to know if it came from the content of the file would be to paste it in the main file.

If that test doesn't give anything make sure PHP has enough permissions to read the concerned file.

RageZ
A: 

Is it reasonable to assume that the real file that won't include is not called problem_file.php? If that is so, then perhaps your file name has characters (like spaces) that need to be escaped.

dnagirl
Your'e right, but the file is set up as listed, aka two words with a _ separating them. No spaces or any other special characters.
canadiancreed