Set character set using MySQLi

It’s the same:

$mysqli->query(“SET NAMES ‘utf8′”);

From the manual:

This is the preferred way to change the charset. Using mysqli::query()
to execute SET NAMES .. is not recommended.

$mysqli->set_charset("utf8"); is just enough, let the mysqli db driver do the thing for you.

Leave a Comment