I am executing the following statement.
$mystring = <<<EOT
UPDATE sites_niche SET `short_review` = REPLACE(`short_review`, '’',"'");
EOT;
However, it doesnt work, as it would work if I placed it in my phpmyadmin. The culprit is this bad character ’
that character is simply not being replaced.
I tried to print the update statement to the screen and I get this:
UPDATE sites_niche SET `short_review` = REPLACE(`short_review`, '’',"'");
I think that the string gets garbled as soon as it goes to the database. My question is how do encode those sets of characters ’
so that they dont get garbled as soon as they go to the database.
You can use the iconv extension http://es.php.net/manual/en/function.iconv.php or mbstring http://es.php.net/manual/en/function.mb-convert-encoding.php to convert a string from one charset to other charset
There are two problems that I am able to see in your posting .
If you dont know which is your encoding format you can use php mb_detect() function to check the character encoding format and use the identified format for the solutions below
Solution : - Your php code which is responsible for connecting to Mysql should use
mysql_set_charset ( string $charset [, resource $link_identifier = NULL ] )
2 .when you print characters are garbled
Solution : - You have to set the character encoding in the page doctype declaration otherwise you will see this garbled characters