Solved

is_dir is not working. Symlink problem??

Posted on 2011-09-08
4
727 Views
Last Modified: 2012-05-12
in my code i have

$usersdir = /home/events/html/userdirs

    if ( !file_exists($usersdir) || is_dir($usersdir)){
        throw new Exception('Internal Error. '.$usersdir.' userdir does not exist');
    }

i get the error
PHP Fatal Error:  Internal Error. /home/events/html/userdirs userdir does not exist'

this does not make sense.
the only thing i can think of is that  /home/events is a symlink.
apache has followsymlinks and all that seems to work.

i found somewhere that is may be php safemode , but from my php.ini i have
safe_mode = Off

Thanks for any help

0
Comment
Question by:paries
4 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 36507982
>>$usersdir = /home/events/html/userdirs
needs quoting:

$usersdir = '/home/events/html/userdirs';

try a ! in front of is_dir() as well:

 if ( !file_exists($usersdir) || !is_dir($usersdir)){
     throw new Exception('Internal Error. '.$usersdir.' userdir does not exist');
    }
0
 
LVL 4

Expert Comment

by:David Linker
ID: 36508126
Could this be a permissions problem - the account under which apache is running doesn't have rights to the directory.
0
 
LVL 7

Expert Comment

by:Vimal DM
ID: 36508128
Hai,

If your checking for the directory,plz do you only for the directory check alone
0
 

Expert Comment

by:saurabhgoyalwebexpert
ID: 36508553
As per your code the error (Internal Error. /home/events/html/userdirs userdir does not exist) is shown When either userdirs does not exists or it is a directory . And I think userdirs is a directory that why this error message is shown . So,Please cross check your code with ur  logic.

Regards
Saurabh Goyal
LAMP Expert
http://sggoyal.blogspot.com
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question