tags:

views:

151

answers:

5

I'm having a critical issue where my WAMP installation for PHP 5.3.0 is not finding a file which exists within my computer. Does anyone know anything about this? Possibly a PHP Bug? Any help would be much appreciated.

Here is the variable which creates the file:

$baseNewsUrl = "C:/reviews/reviews/$platform/$fullname";

And here is the code which grabs the contents:

if(is_file($baseNewsUrl)){
    $contents = file_get_contents($baseNewsUrl);
} else {
    echo "File not found. " . "\r\n";
    continue;
}   

Here is the output of $baseNewsUrl: C:/reviews/reviews/GBA/r20107_GBA.htm And the file does exist.

A: 

Check that the entire path leading up to your file is readable by the user PHP is running as (if you are using IIS, this might be something like "Network Service," although I am not particularly experienced with PHP on Windows). Also, check whether the INI directives "open_basedir" or perhaps "safe_mode" are set--these would give PHP self-imposed limits on which files are accessible.

Tim Yates
A: 

Do a var_dump (not an echo) on your variable.

var_dump($baseNewsUrl);

and look at the actual contents. You may have some invisible garbage characters in there that's preventing Windows if you're doing this in a browser to make sure there's no empty tags (or other browser-render-invisible) characters.

If that doesn't reveal anything, remove the is_file check and try to open the file with file_get_contents (or any file related function) and var_dump it's contents. You'll either open the file, or PHP will spit out an error/warning/notice (either to your browser or to your error log) that should let you know why it can't open the file.

Alan Storm
A: 

I'm gonna say this, and it very well might not be your problem but it is a recurring one for me. If you use skype on your computer, it has a somewhat known compatibility issue with WAMP. It cause's WAMP to be unstable, not load files properly.. everything.

AFK
A: 

It's due to Windows Vista and WAMP.

Jonathan Kushner
A: 

on windows

$baseNewsUrl = "C:\\reviews\\reviews\\$platform\\$fullname";
RafH
You should ALWAYS use the frontslash character for accessing path names in PHP. "C:/reviews/reviews/$platform/$fullname" is the preferred way to access files.
brandon k