Basically, I have a form that restaurant owners can fill out that (among other things) asks for the business name.
If something like “Foobar Café” is entered, it is stored in the MySQL database as “Foobar Café”. Why is it doing that?
Both the HTML page and database table are set to UTF-8 encoding (the “business_name” field has a collation of “utf8_unicode_ci“). Shouldn’t that take care of everything? What exactly could be causing the special character "é" (&etilde;) to be stored in the database as "é"? It makes no sense.
I’m guessing it is from the form not mysql since the email comes from there. Look into that. Maybe you have a ”pre processor” of some sort.
Just wondering, why do you store html chars when you will be displaying that info to users? That’s a recipe for disaster. XSS.
A quick fix, try using htmlentites on the data with uft-8 turned on. Send the email as html and you should be fine.
However, try to find the cause of the issue.
Edit.
echo htmlentities($str, ENT_QUOTES, “UTF-8”);
That should solve your issue. Charset for utf 8 must be defined