Fixed Lua error with cached queries and MySQL.
Fixed queryValue printing the previous error when using SQLite.
Merge pull request #802 from Bo98/database-fixes

Database error fixes