Use php stripslashes function.
here is the link : http://www.php.net/stripslashes
質問
My problem is, that when is post a article on my CMS containing this kind of chars " or '
On my news it displays like this This is John\'s first post!
How do i fix it? Thank you !
Add.php
<?php
session_start();
include_once('../includes/connection.php');
include_once('../includes/infos.php');
if (isset($_SESSION['logged_in'])) {
if (isset($_POST['title'], $_POST['content'])) {
$title = $_POST['title'];
$content = nl2br($_POST['content']);
if (empty($title) or empty($content)) {
$error = '<div class="alert alert-danger"><b>Erreur</b> : Tous les champs sont requis!</div>';
} else {
$query = $pdo->prepare('INSERT INTO articles (article_title, article_content, article_timestamp) VALUES (?, ?, ?)');
$query->bindValue(1, $title);
$query->bindValue(2, $content);
$query->bindValue(3, time());
$valide = '<div class="alert alert-success">Le news a été ajouté</div>';
$query->execute();
}
}
include_once ('inc/header.php');
?>
正しい解決策はありません
他のヒント
Use php stripslashes function.
here is the link : http://www.php.net/stripslashes