0

When a post is edited, the text will save and be cut off at the apostrophe, the character for apostrophe does not appear too. The weird thing is if you go to add event page, the info will not be saved in database if the text includes apostrophe. I tried set charset utf8 but that had no effect (This method get from forum).

Can anyone suggest a solution for allowing the character for apostrophe? Following is part of my code, I will provide any info if you need.

<textarea class="text-input textarea wysiwyg_mini" name="description" style="height:220px"><?php echo $page['description']; ?></textarea>

Any guidance would be appreciated.

Evelyn
  • 656
  • 7
  • 29
  • It's not completely clear to me from the description what you're doing, but it sounds like you're getting string truncation passing text across different character encoding boundaries. Try reading the following post/answer, come back with some more detail if it doesn't help - http://stackoverflow.com/questions/18138097/iso-8859-1-character-truncates-text-inserting-into-utf-8-mysql-column/26876779#26876779 – Peter Barton Mar 06 '15 at 06:14
  • I'm getting string truncation passing text across apostrophe only. For example : "The world's most interesting stories" and I get "The world". The text is truncated at apostrophe. Not so similar to the case you share. – Evelyn Mar 06 '15 at 07:42
  • Sounds almost like it is being treated like a string delimiter then, i.e. 'The World' - try escaping the apostrophe with a '\' first. – Peter Barton Mar 06 '15 at 07:58
  • It works properly with '\' and others character. Only cannot for apostrophe. – Evelyn Mar 06 '15 at 08:34

1 Answers1

0

Solved this by using mysql_real_escape_string to escape special characters in a string for use in an SQL statement. The example code is shown below

$description=sanitize_html(mysql_real_escape_string($_POST['description']));
Evelyn
  • 656
  • 7
  • 29