File open error

Hi,

the fopen in the below code excerpt takes the FALSE path after confirming that the file exists. I’ve confirmed I don’t have it opened and it has 0644 permissions. Anything else I can look at to zero in on the error? Or some way to coax an error code or message from php?

Thx,
Ty

if(file_exists($fName) == FALSE) {
    echo "file doesn't exists<br />";
}else{
    echo "file exists<br />";
    if (($file =  fopen($fName)) == FALSE) {
        echo "file NOT opened<br />";
}else{

Php’s error_reporting should be set to E_ALL and display_errors should be set to ON, preferably in the php.ini on your development system, so that php will help you by reporting and displaying all the errors that it detects. Stop and start your web server to get any changes made to the php.ini to take effect, and use a phpinfo() statement in a .php script file to confirm that the changes actually took effect.

Thanks. The display_errors helped. I also set log_errors=on but still not getting an error log. Any ideas on that?

When something doesn’t work, you must tell us what you tried. In this case, where did you look for the errors to be logged? What is the value of the error_log setting?

Apologies for that. I found the issue. I had set the log_errors value in php.ini to 1 thinking that would enable the error_log file. But after posting here, noticed that a file named “1” was created so changed php.ini to “Error_Log” and I’m now seeing that file.

Sponsor our Newsletter | Privacy Policy | Terms of Service