2014-09-30 26 views
0

我在mysql中存儲ASCII字符,但更新記錄時,ASCII字符轉換爲符號字符!更新mysql中的ASCII字符

對於存儲:

<textarea id="post_entry" class="text" cols="90" rows="18" name="post_entry"></textarea> 

-

$post_entry = $_POST['post_entry']; 
docommand("INSERT INTO post (post_entry) VALUES('".$post_entry."')"); 

FOR UPDATE:

<textarea id="post_entry_edit" class="text" cols="90" rows="18" name="post_entry_edit"><?php echo $row['post_entry']; ?></textarea> 

-

$post_entry_edit = $_POST['post_entry_edit']; 
docommand("UPDATE post SET post_entry='$post_entry_edit' WHERE id = '$post_id'"); 

謝謝。

+0

什麼字符編碼/歸類您使用? – 2014-09-30 07:36:27

+0

UTF8/utf8_persian_ci – 2014-09-30 07:53:49

+0

哪些字符受到影響? – 2014-09-30 08:09:48

回答

0

我的問題已經得到解決:對

<?php 
$raw_html = $row['post_entry']; 
$to_textarea = preg_replace('/&(\w+;)/', '&amp;$1', $raw_html); 
?> 
<textarea id="post_entry_edit" class="text" cols="90" rows="18" name="post_entry_edit"><?php echo $to_textarea; ?></textarea> 

Source <<<