Use parameterized sql and print some better errors.
Add functionality to store and send statistics.