You can’t set the global server character set, because that’s a system wide property. You could try setting it for just the connection though, by using that statement without the global word.
However, you will probably want to set the MySQL charset through the PHP connection code instead, because I’m not sure that setting it with the SQL statement works.
This article has more information about why this issue happens, and how to fix it: