You declared the variable in one function and used it in another. When you create a variable in a function, it is automatically deleted when the function is exited. You must globally declare it in the main part of your program. Hope this helps.
EDIT: you used them in the main part, but you must specifically GLOBALLY declare them before you use them.