Variable scope

A variable is only valid in the function it was declared. To make it valid for all functions declare it at the top of the code before any function.

If you want specific help with your problem please post the code you are having trouble with.