I am trying to write to a MySQL database properly, but it's giving me HTML Entities instead of the character I want.
My page header contains...
<meta charset="utf-8">
Here's the code I'm using...
$team_name = "Ranieri's Ghost";
$team_name_converted = html_entity_decode($team_name, ENT_COMPAT, "UTF-8");
mysqli_query($con,"INSERT INTO mydbname (team_name) VALUES ('$team_name_converted') ");
echo $team_name_converted;
- Echoed to screen:
Ranieri's Ghost - Entry in MySQL Database:
Ranieri's Ghost
I know this is susceptible to SQL injection but I'll sort that once fixed.
The SQL Table row is a VARCHAR (40) and I have tried collation "utf8_roman_ci", "latin1_swedish_ci", "utf8_swedish_ci", "utf8_general_ci" and a few others but it didn't seem to change much.
Any idea how I can get it to write Ranieri's Ghost into my MySQL database without the special characters?