Just to clarify... the reports you are getting about undefined variables are "NOTICES"... which is the lowest level of reports. They are "things that you oughtta know", but they don't really have any impact on your script.
You can change the specified reporting level to not display NOTICE reports, but still report "warnings" and "errors". This will get rid of these not so important messages, but will still help you when you have real problems.
-Ryan