Make sure that you've changed the permissions on your script file so that it's executable, i.e. (if you're running under Unix):
It's also a good idea to check that the directory that you're trying to create a directory in has write permissions for the webserver... you definitely want to contain such scripts as this in their own subdirectories of the cgi-bin directory, and grant permissions to just those directories, or you're looking at possible security holes.