tags:

views:

40

answers:

2

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 am 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

+1  A: 

All files in the subdir cfg get this error, but not those in other subdirs.

Try:

require("cfg.database.inc.php");
babonk
Doesn't work, sorry. Can you explain why you think it should?
opatut
Because if you're already in cfg, then cfg/cfg.database.inc.php would be cfg/cfg/cfg.database.inc.phpCan you also try require("/cfg/cfg.database.inc.php"); ?
babonk
No I am in /, and none of your suggestions works. I think there is some invisible character or something stupid like that...
opatut
+1  A: 

There's usualy two reasons for this kind of behavior

  1. 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

  2. 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.

Alan Storm
Seems like it was number 2. I renamed my file names, but I didn't keep the ".php" this time, like Windows Explorer suggested. Seems like there was some invisible character in it...
opatut