title: inserting special chracters into mysql using perl
body: <p>hi i am very new to perl.. 
  I have a temp_data.txt file like this </p>
  
  <pre><code>Id    Comments
  --------------------------------
  1      this is a 'comment'
  2      special comment
  3      user comment 'user'
  -----------------------------------
  
  
    open (MYFILE, 'temp_data.txt');
  while (&lt;MYFILE&gt;) {
  if($_=~/^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)/)
  {
      $id=$1;    
      $comment = $2;
  }
  
  while(&lt;MYFILE&gt;)
  {
      $line=$_;
      if($line=~/^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)/)
      {
          seek(MYFILE, -length($_), 1);
          last;
  }
      else
      {           if($_=~/\s*(.*)/)
          {
              $comment .=$1;
  
          }
      }
  }
  
  my $queryString = "INSERT INTO Headline (id,comment) VALUES ('$id', ' $comment')";
  
  $sth = $dbh-&gt;prepare($queryString);
  $sth-&gt;execute() or die $DBI::errstr;
  $sth-&gt;finish();
  }
  </code></pre>
  
  <p>but while inserting into data base if it encounters a special character throwing a error like this.</p>
  
  <pre><code>DBD::mysql::st execute failed: 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 'comment')' at line 1 at head.pl line 1.
  </code></pre>
  
  <p>can anyone help me?
  thanks in advance</p>