It looks like you might be hitting problems with some of your variables not getting set correctly. To debug, try adding an echo line for each variable just before you go to use it to check everything is as it should be.
Also, check that you are using the right comparison operator, I'm pretty sure = works for numbers, not quoted strings.
Rules of unix.com prevent very explicit help on classwork but I'm sure we can help you on useful debugging steps.
