Always wrap your code in [php][/php] or [code][/code] tags. It preserves the formatting. Also, in the future please select a more suitable title for your threads.
These comparisons are wrong. You cannot reliably compare a string value of "Y" with that of "Y". Use
avariable.equalsIgnoreCase("Y") etc as your comparisons.