PHP "No such file or directory" - but it should be there
I just got a strange problem. I am including some files from my index.php, and now I got this error:
require(cfg/cfg.database.inc.php) [function.require]: failed to open stream: No such file or directory in C:\...\index.php on line XX
Strange is that it worked just a minute ago. I double checked the spelling of that filename.
What I did: I a开发者_StackOverflow社区m using Notepad++ and I saw my code like this:
require("cfg/cfg.database.inc.php" );
I wanted to remove the space between "
and )
, so i moved the cursor there and pushed Del, but it deleted the last p
of .php
.
I deleted the whole line and rewrote it, and now I get the error that the file cannot be found. I also renamed the file which is not working. All files in the subdir cfg
get this error, but not those in other subdirs.
Anyone knows what I am doing wrong or what I can do to find the problem? Thanks.
/edit: My file structure
index.php
cfg/cfg.database.inc.php
cfg/cfg.other.inc.php
core/class.user.inc.php
core/...
All includes in core
work, none of those from cfg
There's usualy two reasons for this kind of behavior
Your PHP file and/or your file name has a character that's rendering to the screen as a standard, ascii letter, but is in fact some other letter in another encoding
You have multiple cfg folders, and PHP is looking in the wrong one.
Give this s try to see which cfg folder (relative to your running script) PHP sees, and what files it sees in there.
$my_cfg_files = glob('./*');
Next, try requiring files by iterating the loop
header('Content-Type: text/plain');
foreach($my_cfg_files as $file)
{
echo 'trying ' . $file . "\n";
require_once($file);
}
exit("\n Done \n");
Take a look at the list of files that it outputs. Copy what the scripts prints and include it in your require statement.
All files in the subdir cfg get this error, but not those in other subdirs.
Try:
require("cfg.database.inc.php");
There might be a space:
require("cfg.database.inc.php ");
Remove it:
require("cfg.database.inc.php");
精彩评论