2

I'm having a niggling wordpress problem

Whenever i'm adding an Apostrophe to a wordpress post I create

'

Its saving as a strange set of characters

’

I've used wordpress many times, never encountered this problem

I've uninstalled every single plugin, and the problem remains

I read somewhere to comment out these lines in wp-config.php but it doesn't help for new posts

/** Database Charset to use in creating database tables. */
//define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
//define('DB_COLLATE', '');

Can someone help me? DO need to set the Charset to override somewhere? How??

s_ha_dum
  • 2,840
  • 2
  • 18
  • 23
Raphael Gluck
  • 86
  • 2
  • 10

3 Answers3

1

If that strange character is stored in DB, then it seems that your DB is not set up with the UTF8 charset, so you can uncomment those 2 lines in wp-config.php, since they are not the source of the problem.

You have a comprehensive tutorial how to convert Character Sets with WordPress Database but here is the short list what to do:

  • Make a backup of your DB
  • Maybe it would be better make a copy of your site on your local computer and try the below changes there

  • Convert DB (this will not affect existing tables, just those future new created tables)

    ALTER DATABASE MyDb CHARACTER SET utf8;

  • convert any tables in the database that are not already in the desired format.

    Focus on the tables wp_posts and wp_postmeta

    ALTER TABLE wp_posts CHARACTER SET utf8

    ALTER TABLE wp_postmeta CHARACTER SET utf8

  • individually alter each column of each table to use the correct the character set. This is not a simple process, read carefully the section of above link regarding columns.

Salomon Zhang
  • 1,553
  • 3
  • 23
  • 41
user850010
  • 6,311
  • 12
  • 39
  • 60
  • I tried following that, namely ALTER DATABASE MyDb CHARACTER SET utf8; convert any tables in the database that are not already in the desired format. Focus on the tables wp_posts and wp_postmeta ALTER TABLE wp_posts CHARACTER SET utf8 ALTER TABLE wp_postmeta CHARACTER SET utf8 but to no avail, though I do feel we're on the way to solving!! Thanks – Raphael Gluck Apr 05 '13 at 23:07
  • Try opening some post in editor that contains that strange character and replace it with apostrophe and save that post. Does the apostrophe get saved correctly now? – user850010 Apr 06 '13 at 07:12
  • In the editor, everything seems ok, its only when i am viewing front end that this problem is occurring . thank you – Raphael Gluck Apr 08 '13 at 02:02
  • in myPHPAdmin, your your DB,Tables,Columns should say UTF-8 and also your website should use UTF-8. View one of the page with this problem and then look into the generated source code. In the beginning (in the head tag) what charset is used? For my site I have . You could also view source code when you are in editor, to check what charset is used there. – user850010 Apr 08 '13 at 07:30
  • Also check .htaccess file. It is also possible that some non UTF-8 charset is set there. http://www.askapache.com/htaccess/setting-charset-in-htaccess.html – user850010 Apr 08 '13 at 08:01
1

I have to update the thread, as follows. I followed just about every tutorial out there addressing utf-8 mismatch, nothing helped Finally we spotted some phishing code had been injected into the root index file (also linked to some 3rd party adult site, but our site was not redirecting , Needless to say, we cleaned that up Many thanks for everyone for helping, especially @user850010 I hope This thread will be useful for others

Raphael Gluck
  • 86
  • 2
  • 10
-1

Run this query:

ALTER DATABASE MyDb CHARACTER SET utf8;

After edit wp_config.php and set:

define('DB_CHARSET', 'utf8');
vard
  • 4,057
  • 2
  • 26
  • 46