Tested:
Mysqli_query ("Set nams UTF8") must return false before all statements are executed.
Look at the manual, said not recommended to use Mysqli_query to set the code, with Mysqli_set_charset, but if this method is required: If you use this method on the Windows platform, Requires 4.1.11 version or more of the MySQL client library, and the MySQL version is 5.0.6 or more.
What's the difference between MySQL client library and MySQL version, I haven't figured it out yet.
UTF8 can not be written utf-8, because the MySQL command mode can only identify "UTF8", do not recognize the "utf-8", but in PHP header to add "-", because IE does not know the "UTF8" without the bar.
"UTF-8" is the standard way of writing, English is not case-sensitive under windows, so it can also be written as "Utf-8". It is best to write in the standard, written in uppercase.
Mysqli_query ("Set NAMs UTF8") is false