In the original source code $sitename is being used BEFORE it has been declared and given a value. Other errors have been mentioned already.
If you're new to shell scripting, you should test after each new added line to see if it does what you want.
Based on the code it seems you are trying to do certain things like C-style programming. If that is really the case and you have PHP installed on your system, you should try PHP for commandline scripting - it doesn't need a webserver to work.