我想关掉PHP的魔术引号.我无法访问php.ini.
当我尝试添加php_flag magic_quotes_gpc off到我的.htaccess文件时,我收到500内部服务器错误.这是我的.htaccess文件的样子:
AddType x-mapp-php5 .php
php_flag magic_quotes_gpc off
Run Code Online (Sandbox Code Playgroud)
然后我尝试使用ini_set('magic_quotes_gpc', 'O'),但这没有效果.
如何关闭魔术报价?
该$_POST['reply']变量包含html标签,<p>text goes here</p>但我无法将其插入数据库.因为reply我使用TinyMCE,当我不使用它(输入为无标签)时,text goes here它被正确插入.
我在这里错过了什么?
try {
$db = new PDO(DB_DRIVER . ":dbname=" . DB_DATABASE . ";host=" . DB_SERVER, DB_USER, DB_PASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $db->prepare("INSERT INTO replies(article_id, comment) VALUES (:article_id, :comment)");
$stmt->bindParam(':article_id', $article_id, PDO::PARAM_INT);
$stmt->bindParam(':comment', $_POST['reply'], PDO::PARAM_STR);
if($stmt->execute()) {
echo 'success';
}
$db = null;
} catch(PDOException $e) {
trigger_error('Error occured while trying to insert into the DB:' . $e->getMessage(), E_USER_ERROR);
}
Run Code Online (Sandbox Code Playgroud)
这是表单代码: …