Salve utenti,
vi espongo il mio problema
quando vado ad inserire dei dati con apostrofo in un database,tramite form, mi da questo errore "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'parola che viene dopo l'apostrofo'' at line 1

ho provato tutto ma non funziona

ecco i codici

add_article.php:
codice:

Codice PHP:
<?phpsession_start();if(isset($_POST['submit'])){    include 'article_functions.php';    include 'title_function.php';    $title $_POST['titolo'];    $details $_POST['descrizione'];    $meta_tag_title $_POST['meta_tag_title'];    $meta_tag_details $_POST['meta_tag_description'];    $pageClass= new pageClass();    $alert=$pageClass->addPage($title,$details,$meta_tag_title,$meta_tag_details);    $getArticle =$pageClass->getArticle($_POST['titolo']);    $value $pageClass->getArticle($_POST['titolo']);    print_r($value);    $titleClass= new fileName();    $title $titleClass->generateFilename($_POST['titolo'],30);    //$name_page_complete = str_replace(" ","_",$name_page_complete);    $fo = fopen($title,"w");    $code = '<?php include("article_functions.php");     $pageClass = new pageClass();     $id = '.$value['id'].';     $pageClass->getArticleById($id);     $value = $pageClass->getArticleById($id);    ?>
codice:
      <html>
      <head>
      <title><?php echo $value["meta_tag_titolo"];?></title>
      <meta name="title" content="<?php echo $value["meta_tag_titolo"];?>">
      <meta name="description" content="<?php echo $value["meta_tag_descrizione"];?>">
      </head>
      <body><?php echo $value["descrizione"]; ?>
      <h1><?php echo $id;  echo "'.$title.'"?></h1>
      </body>
      </html>';
    fwrite($fo,$code);
    fclose($fo);
  }
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Add</title>
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.css">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="//cdn.ckeditor.com/4.8.0/standard/ckeditor.js"></script>
  </head>
  <body>
    <?php include 'include/header_admin.php'; ?>
    <h1>Add Article</h1>
    <form class="" action="add_article.php" method="post">
      <label for="">Titolo</label><br>
      <input type="text" name="titolo" value=""><br><br>
      <label for="">Descrizione</label><br>
      <input type="text" name="descrizione" id="descrizione" value="">
      <label for="">Meta-tags Titolo</label><br>
      <input type="text" name="meta_tag_title" value=""><br><br>
      <label for="">Meta-tags Descrizione</label><br>
      <input type="text" name="meta_tag_description" value=""><br><br>
      <button type="submit" name="submit">Pubblica</button>
    </form>
  </body>
</html>
funzione addPage:
codice:

codice:
public function addPage($title,$details,$meta_tag_title,$meta_tag_details)
{
  $conn = mysqli_connect("localhost","root","","tributi_comunali");
  $title = htmlentities($title);
  echo $title;
  $details = htmlentities($details);
  $meta_tag_title = htmlentities($meta_tag_title);
  $meta_tag_details = htmlentities($meta_tag_details);
  $insert="INSERT INTO articoli (titolo,descrizione,meta_tag_titolo,meta_tag_descrizione) VALUES ('$title','$details','$meta_tag_title','$meta_tag_details')";
  $result=mysqli_query($conn,$insert);
  if ($result) {
    return "Values are added to our cms page";
  }
  else {
    return "some errors";
  }
}