Take the 2-minute tour ×

How can i vanish out the odd string like � in php?

i already use like html_entity_decode php function but it's still not works.

anyone can help ?

share|improve this question
This is an encoding problem. Do you have a <meta charset that is consistent with what your server sends? –  PhpMyCoder Jul 17 '12 at 3:56
This is usually caused by mixed character encodings. Make sure the page's character encoding is the same as the server. –  pyrokinetiq Jul 17 '12 at 3:57
fix the problem not the symptoms –  Dagon Jul 17 '12 at 3:58
FYI, the character '�' is U+FFEF, "REPLACEMENT CHARACTER". –  Keith Thompson Jul 17 '12 at 4:02
posting some relevant codes might help –  deex Jul 17 '12 at 4:03

4 Answers 4

up vote 4 down vote accepted

Try to add these line in your db config file.

if (!$con)
mysql_select_db("db_name", $con);

share|improve this answer
that's make my day... –  Gunslinger_ Jul 17 '12 at 6:28
You might want to consider upgrading to PDO -- the old style SQL functions are horribly insecure. Bound statements are not only quicker and more efficient, but they transparently quarantine inputs so you don't have to worry about injection attacks. Little Bobby 'Drop Tables' loves playing games with old-style SQL commands. –  RonLugge Jul 17 '12 at 20:08

� isn't just one symbol -- it's the symbol used to replace a symbol that your browser can't make sense of. Usually this is caused by encoding issues -- you set the wrong encoding, or someone is using a symbol from a different encoding.

You can't just magically strip it out, because it isn't just one character. Simply put, encoding is one place where you can't just wave a magic wand -- you have to decide on an encoding, and then enforce it.

If you're taking user input, I honestly don't have any clue how to help with the issue. You can check for common causes (curly quotes and dashes as distinct from hyphens are where I run into this the most), and force a manual replace on them, but if a user wants to enter in a badly-encoded character, there's not a lot you can do.

share|improve this answer
+1 because you mentioned "you have to decide on an encoding, and then enforce it." you are absolutely right about this. –  JRSofty Jul 17 '12 at 6:28

Try changing your <meta charset to iso-8859-1 like

share|improve this answer

If your content is in ANSI encoding use


you can check the encoding of your files using a editor like ( NOTEPAD ++ )

share|improve this answer

Your Answer


