2014-02-23 20 views
0

我的問題是,那個時候是張貼在我的CMS含有這種字符" or '我的PHP文章有錯誤

我的新聞會顯示這樣的This is John\'s first post!

如何解決它的文章?謝謝 !

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');  
?> 
+0

顯示所述內容的代碼在哪裏? –

+0

謝謝,快速回答,但傑弗裏卡蘭丹已經幫助我;) – ProtectorOfTheRealm

回答