在存入数据库之前先替换掉,以下是一些替换:
function safe_convert($d) {
$d = str_replace("'","'",$d);
   $d = str_replace("\t","",$d);
   $d = str_replace("<","&lt;",$d);
  $d = str_replace(">","&gt;",$d);
   $d = str_replace("|","&#73",$d);
   $d = str_replace("  ","&nbsp;",$d);
   return $d;
}
存入数据库之前先用safe_convert($d)将这段字符串里面的可能会引起问题的字符替换掉

解决方案 »

  1.   

    简单的方法:
    insert into send (data)values('what''s matter with the system')
      

  2.   

    简单的方法:使用双引号来界定
    insert into send(data) values("what's matter with the system");
      

  3.   

    先赋值在插入,形成习惯,有好处.
    $value="what's matter with the system";
    insert into send(data) values($value);
      

  4.   

    建议采用 sakura169(淡淡)的方法,我觉得不错的
      

  5.   

    sakura169(淡淡) 不可取, 他改變了原始資料.
    正確的做法是採用 Mysql 的Escape 定義。
    使用 \ 或 重複引號
    或者乾脆使用不同的引號包含 。
      

  6.   

    insert into send (data)values('what's matter with the system') 改成
    insert into send (data)values('what\'s matter with the system')