Okay, I'm speaking a little out of turn here and may be incorrect. (where's jdMorgan when you need him . . . ) This is probably a related issue, one of ownership. If you uploaded and created this directory via ftp, the owner is you, which is your user name for FTP. When your script goes to change mode on a file, it's doing so as the user Apache. So Apache can't change permissions on a file owned by you.
The solutions: have your script write the directory, it will then be owned by Apache. Not as difficult as it sounds, and is good programming practice to check for any resource before trying to write to it. Pseudo-code would be something like
if (-d $directory) { // -d = is a directory
.... do something in $directory
}
else {
system(`mkdir $directory 655`);
... do something in $directory
}
Once run the first time, it will never use that "else" again.
Another thing you can do is SSH in, sudo su which makes you "pseudo-root" and set permissions. Granted, the directory is now owned by root, so you might want to also chown to Apache or neither the script or you as an FTP user can do anything but delete it.
Again, I'm a little gray on system issues but using one of the above usually gets you to a point where you can write safely to a directory.