added check for valid charset values

To ensure that the $encoding parameter is valid, I have added a check that retrieves all valid charset values from the current mysql connection, and checks if the requested encoding is a valid value. If not it will simply fail silently, skipping entirely the SET NAMES statement.