Move the SQL input sanitization code into its own function.