searching directories

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phierce
Forum Newbie
Posts: 3
Joined: Thu Jan 27, 2005 7:47 pm
Location: Denver, CO
Contact:

searching directories

Post by phierce »

I neen to write a script to "audit" email accounts on my website. All the accounts should have a number in them that coresponds to the users employee ID. For example John Smith has employee IF 105, his email account is john105@xxx.com.

Now I have all the directories and I am retrieving a list of inactive people from my database and I am trying to check if a directory with thier name+id exsists, but I am having troubles, here is how I am trying it

Code: Select all

$checkDir = &quote;/home/xyz/mail/xyzmail.com/&quote;.$inactiveї&quote;firstName&quote;].$inactiveї&quote;id&quote;];
if(is_dir($checkDir))
{
     printf(&quote;<tr><td>%s %s</td><td>%s</td><td>%s</td><td>%s%s</td></tr>&quote;,
     $inactive&#1111;&quote;firstName&quote;], $inactive&#1111;&quote;lastName&quote;], $inactive&#1111;&quote;plsid&quote;], $inactive&#1111;&quote;emailAddress&quote;],
     $inactive&#1111;&quote;firstName&quote;], $inactive&#1111;&quote;id&quote;]);
}
Nothing is happening even if I do

Code: Select all

echo is_dir('$checkDir');
but I can do

Code: Select all

echo is_dir('/home/xyz/mail/xyzmail.com/john105');
A better solution if anyone can help me is to just have a function that says "Is there a directory that contains '105' in it?" and return that directory.

Thanks if you can offer any help!
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

Code: Select all

echo is_dir('$checkDir');
variables will not parse inside single quotes. ;)
should be:

Code: Select all

echo is_dir($checkDir);
or, if you really want to use quotes...

Code: Select all

echo is_dir("{$checkDir}");
I'd simply write...

Code: Select all

if (is_dir("/home/xyz/mail/xyzmail.com/{$inactive['firstName']}{$inactive['id']}")) {
  // ^_^
}
Post Reply