duanli9930 2012-09-12 07:32
浏览 19

在php中编码一个字符串

I am executing the following statement.

$mystring = <<<EOT
UPDATE sites_niche SET `short_review` = REPLACE(`short_review`, '’',"'");
EOT;

However, it doesnt work, as it would work if I placed it in my phpmyadmin. The culprit is this bad character ’ that character is simply not being replaced.

I tried to print the update statement to the screen and I get this:

UPDATE sites_niche SET `short_review` = REPLACE(`short_review`, '’',"'");

I think that the string gets garbled as soon as it goes to the database. My question is how do encode those sets of characters ’ so that they dont get garbled as soon as they go to the database.

  • 写回答

2条回答 默认 最新

  • dongwen2162 2012-09-12 07:38
    关注

    You can use the iconv extension http://es.php.net/manual/en/function.iconv.php or mbstring http://es.php.net/manual/en/function.mb-convert-encoding.php to convert a string from one charset to other charset

    评论

报告相同问题?

悬赏问题

  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题