10
You're repeating yourself
Seriously, though. The variables were likely cached in your PHPsession information, although I must admit that I haven't yet pursued that part of the code, so can't say for sure, but it's likely not an issue overall.
Back to your troubleshooting....
Before the database failed part, did you get a green light on the ability to talk to the database? Are you sure that you were connected to the database with correct user settings and such, password and all?
It seems weird that you can get past that point, but then you can't create the tables. Does the user that you created for this access to the database have all privileges?