First of all, you should first fix the errors in your code before you can expect things to work as expected:
Unfortunately, it’s impossible to provide the help you need without seeing the problem that you described.