set_charset("utf8"); ?>
prepare("SET NAMES ?;"); $stmt->bind_param("s", $charset); $charset = "latin1"; $stmt->execute(); ?>In this example, the mysqli object is created with the credentials to connect to the MySQL database. A prepared statement is created to set the character set using the SET NAMES command, which is then executed. The character set is set to Latin1 by binding a variable to the prepared statement and setting it to "latin1".