title: pdo prepare escaping single quotes
body: <p>I use PDO in a web application I am building. I always thought (I am wrong actually) that using <code>prepare</code> should help with single quotes in the inserted variables but it seems that I miss something. I get an error inserting values like <em>L'Aquila</em> where there is a single quote in the input data. </p>
  
  <p>My actual code is:</p>
  
  <pre><code>        $sql = "INSERT INTO anagrafiche SET
          id_ndg = '$protocol',
          nick = '$nick',
          nome = '$nome',
          cognome = '$cognome',
          ragsoc = '$ragsoc',
          leg_rappr = '$leg_rappr',
          cod_fisc = '$cod_fisc',
          p_iva = '$p_iva',
          cf_estero = '$cf_estero',
          SAE = '$sae',
          RAE = '$rae',
          ATECO = '$ateco',
          CRCODE = '$crcode',
          indirizzo = '$indirizzo',
          civico = '$civico',
          cap = '$cap',
          citta = '$citta',
          prov = '$prov',
          tel = '$tel',
          cell = '$cellulare',
          mail = '$mail',
          note = '$note',
          file_ci = '$file_ci',
          file_cf = '$file_cf',
          file_visura = '$file_visura',
          cittadinanza = '$cittadinanza',
          res_fiscale = '$res_fiscale',
          is_curatore = '$is_curatore',
          is_legale = '$is_legale',
          is_tribunale = '$is_tribunale',
          is_fornitore = '$is_fornitore' ";
      try{
          $s = $pdo-&gt;prepare($sql);               
          $s-&gt;execute();
      }
      catch (PDOException $e){
          $error = 'Errori nel caricamento: '.$e-&gt;getMessage();
      }
  </code></pre>
  
  <p>and when I try to load a string containing the single quote I get an error like this while trying to load the string <em>Piazza d'Armi</em>
  :</p>
  
  <blockquote>
    <p>Errori nel caricamento: SQLSTATE[42000]: Syntax error or access
    violation: 1064 You have an error in your SQL syntax; check the manual
    that corresponds to your MySQL server version for the right syntax to
    use near 'Armi', civico = '0', cap = '83100', citta = 'Avellino',
    prov' at line 15</p>
  </blockquote>
  
  <p>What am I missing? I don't think that PDO quote can do the job for me but maybe it's me that I don't get the point</p>