PHP Rename Permission Denied - Error Handlng

My website maintains a database along with a set of folders on my server.  The Syncronization between these is working fine.  By this I mean if you add a record to the table a folder is created with the same name, if you rename the record the folder is renamed to the new name etc etc.

The problem i am having is that becuase we run a Windows 2003 server and remote desktop onto it to do various other file management tasks to the contents within these folders created by the website you can provoke a Permission Denied error on the website by accidently having a file open within a folder that PHP wishes to rename!

I understand that this is what should happen as the results are the same within Windows but instead of my website just keeling over with an error message i would like to pop up a message saying "Folder in use : rename not possible, try again later...." or something along those lines?

I have tried :

if (!rename($old_folder, $new_folder)) .....

But this does not work...

Is there another way around this?
Sailo100Asked:
Who is Participating?
 
m1tk4Connect With a Mentor Commented:
add a @ to rename call in the sample above to suppress the error message:

@rename(...)

=== in PHP means "equal and the type is the same". For example:

(FALSE == 0 ) is TRUE
(FALSE === 0) is FALSE

0
 
dereshConnect With a Mentor Commented:
you could try:

if(FALSE === rename($old_folder,$new_folder))
{
// do something if rename failed
echo "Folder in use : rename not possible, try again later....";
}

http://www.php.net/manual/en/function.rename.php
0
 
Sailo100Author Commented:
What does 3 equal signs mean?
0
 
Sailo100Author Commented:
This does not appear to work....  I still get permission denied?
0
 
Sailo100Author Commented:
Perfect thanks guys!  I've always wanted to know what @ was used for :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.