Database error fixes

* Fixed queryValue printing the previous error when using SQLite.
* Fixed a Lua error on reconnect to a MySQL database after calling queryValue when not connected to the database.