我正在尝试通过 tinymce 插入 html。
例如:
<img title="q" src="../kcfinder/upload/image/3b5330574c883fe1040eaddeb596ea20.jpg" alt="q" width="640" height="480" />
PDO 使这个
<img title=\"q\" src=\"../../../kcfinder/upload/image/3b5330574c883fe1040eaddeb596ea20.jpg\" alt=\"q\" width=\"640\" height=\"480\" />
这是插入动作:
$data = array_slice($data1, 0, -1);
foreach ($data as $column => $value) {
$ins[] = ':' . $column;
}
$ins = implode(',', $ins);
$fields = implode(',', array_keys($data));
$sql = "insert into $this->tableName ($fields) values ($ins)";
$sth = $this->connection->getConnection()->prepare($sql);
foreach ($data as $f => $v) {
$sth->bindValue(':' . $f, $v);
}
return $sth->execute();
我尝试了 str_replace,但这不起作用。有人知道如何删除 \ ?
解决方案:
if (get_magic_quotes_gpc()) {
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
while (list($key, $val) = each($process)) {
foreach ($val as $k => $v) {
unset($process[$key][$k]);
if (is_array($v)) {
$process[$key][stripslashes($k)] = $v;
$process[] = &$process[$key][stripslashes($k)];
} else {
$process[$key][stripslashes($k)] = stripslashes($v);
}
}
}
unset($process);
}