For one, [man]chmod/man expects an integer (usually an octal value) to be passed as the second parameter, not a string.
Second, have you verified that chmod()'s return value indicates that the change was successful? Do you have error_reporting set to E_ALL and either display_errors (development environment) or log_errors (production environment) set to On?
Finally, note that the user who invoked the PHP parser must either a) be a superuser (not likely, and definitely far from good if it is), or b) own the directory in question. Also note that if the latter is the case, and if you are on a shared server that doesn't use open_basedir restrictions, then nothing would prevent anyone else on that shared server from simply re-chmod'ing your directory back to 0777.
In other words, if you're worried about security in any way, you'd better not be on a shared host. 😉