And if you don’t want to worry about so many different encodings or if htmlentities doesn’t work for you, here is an alternative: I used the mysqli DB connection (and PHPV5) form message for writing / pasting to MySQl DB.
$Notes = $_POST['Notes']; //can be text input or textarea. $charset = mysqli_character_set_name($link); //only works for mysqli DB connection printf ("To check your character set but not necessary %s\n",$charset); $Notes = str_replace('"', '"', $Notes); //double quotes for mailto: emails. $von = array("ä","ö","ü","ß","Ä","Ö","Ü"," ","é"); //to correct double whitepaces as well $zu = array("ä","ö","ü","ß","Ä","Ö","Ü"," ","é"); $Notes = str_replace($von, $zu, $Notes); echo " Notes:".$Notes."<br>" ; $Notes = mysqli_real_escape_string($link, $Notes); //for recommended mysqli DB connection. //$Notes = mysql_real_escape_string($Notes); //for old deprecated mysql DB connection. // mysqli_real_escape_string Escapes special characters in a string for use in an SQL statement echo " Notes:".$Notes ; //ready for inserting
source share