$_POST["post_blerb"] = "Warren pretends he�s gay, thinking it will do wonders for his acting career.";
// ^Example ... not really used.
if(!empty($_POST["post_blerb"])){
$post_blerb = htmlentities(trim($_POST["post_blerb"]));
}else{
$error[] = "Empty Post Description";
}
$post_blerb = utf8_encode($post_blerb);
$post_blerb = mysql_real_escape_string($post_blerb);
//Insert into Database
//done
//output database
echo utf8_decode($post_blerb);
//result: Warren pretends he�s gay, thinking it will do wonders for his acting career.
Im stumped at why ’ is being replaced with â�� … Any ideas? :goof:
Are you setting the charset in your html document and forms to be UTF8? You need to do this otherwise data sent through your form will not be in the correct charset.
Also, you need to tell htmlentities to handle utf8 properly, like so:
I fixed it by moving utf8_encode to the beggining before trying to escape any bad code. #1 what caused the � charictor #2 will converting damage escaping html constrictors or mysql_real_escape_string
It was probably a (multibyte?) character that looks alot like a ’ (ascii apostrophe, Unicode character: 0027 hex = 39 dec) , but is one from a word processor program that is (or looks alot like ) the right single quote closing character ’ . ie, Unicode character: 2019 hex = 8217 dec
Copy and pasting from a word processor would cause it.