3

I am building a membership site in WordPress. I have added a Notes functionality on my site where each unique user can login to the site and enter notes specific to each lesson/post. I am storing these notes in a custom table in db.

The user can enter the notes in any preferred language rather than just using English language for entering Notes. Now, the problem is notes are not getting stored properly in db if the user enters it in some other language. For example, if the user enters some characters in Russian language, it gets converted into this form

%u0414%u0440%u0435%u0432%u043D%u0435%u0440%u0443%u0441%u0441%u043A%u0438%u0439 %u043B%u0438%u0442%u0435%u0440%u0430%u0442%u0443%u0440%u043D%u044B%u0439 %u044F%u0437%u044B%u043A %u0438 %u0435%u0433%u043E

I am using the following query for inserting the data in the custom table:

<?php
    $wpdb->insert( 'wp_notes', array( 'userid' => $_POST['userid'], 'postid' => $_POST['postid'], 'note' => ''. stripslashes($_POST['notes']) .'', 'title' => ''. stripslashes($_POST['title']) .'' ),  array( '%d', '%d','%s','%s' ) );
?>

I am already using a meta tag for charset utf-8 and my db is also set to utf8_general_ci Collation.

Any help will be appreciated.

  • What happens in the DB if you enter russian text in a regular post/page? – brasofilo Nov 28 '12 at 11:36
  • If I enter the russian text as a comment or post, it is saved as it is in the DB. – swtshweta Nov 28 '12 at 11:55
  • And what if you do a $wpdb->prepare() before the insert()? – brasofilo Nov 28 '12 at 12:01
  • I tried using this query instead: $wpdb->query( $wpdb->prepare( "INSERT INTO wp_notes (userid, postid, note, title) VALUES (%d, %d, %s, %s)", $_POST['userid'], $_POST['postid'], stripslashes($_POST['notes']), stripslashes($_POST['title']) ) ); but no luck :( – swtshweta Nov 28 '12 at 12:43
  • What happens if you don't use stripslashes? – Otto Nov 28 '12 at 13:10

Browse other questions tagged or ask your own question.