I'm writing a php program that pulls from a database source. Some of the varchars have quotes that are displaying as black diamonds with a question mark in them (�,)
How can I use php to strip these characters out?

7 réponses


Benjamin Derepas
Réponse acceptée

If you are using PDO extension, you can force charset by using params into your PDO objetct

$dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass, array( PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")

Hi,
can't you just change the charset in your html template?

naimo
Auteur

yes I put

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

and problem still unsolved

Check youre file encoding. Set it to UTF8.
We need more precision about this problem. If you juste 'echo ' a special char, it's ok ?
Or maybe it's a var from a database ? If it, it's different !

naimo
Auteur

yes it's a var from a database

naimo
Auteur

yeeeessss it's wwork thanx @Benjamin can I have your email or facebook account ??

naimo
Auteur

Thanx PallMallShow and TransientDev :D