Friday 9 April 2010

Database transfer has put ’ , ‘ , “, Â, ”, –, …, ’ in my text.

Here's how I got rid of these from my database.

On this project I am working with Joomla 1.5 but the following instrunctions are fairly Generic and could be used with other mysql database problems with a little adaption.
The theory of the mysql find and replace is this

UPDATE tablename SET fieldname = replace(fieldname,"valuetofind","valuetoreplacewith");

Note: in this scenario I need to replace with apostrophe's ( ' ) . when doing this they need to be escaped. ie \'

Here are the commands I ran in my phpMyAdmin area.

UPDATE jos_content SET introtext = replace(introtext,"’","\'");

UPDATE jos_content SET introtext = replace(introtext,"‘","\'");

UPDATE jos_content SET introtext = replace(introtext,"“","\"");


UPDATE jos_content SET introtext = replace(introtext,"Â"," ");

UPDATE jos_content SET introtext = replace(introtext,"”","\"");

UPDATE jos_content SET introtext = replace(introtext,"–","-");

UPDATE jos_content SET introtext = replace(introtext,"…",";");


I also had to check the titles of the articles to do this replace 'introtext' with 'title'



Building Websites with Joomla! 1.5: The best-selling Joomla! tutorial guide updated for the latest 1.5 release

No comments: