Duane Hill wrote:
Can someone either answer or point me somewhere for the answer?

I am attempting to store text lines from an e-mail message into a MySQL table through the use of Perl and DBI. Periodically I get the error that states there was an error in the statement and to check the syntax. I know it has something to do with how the statement is being interpreted. Here is the Perl that is in question:

  $sql  = "INSERT INTO msg_line_hash ";
  $sql .= "  (line_text, line_hash, total_count) ";
  $sql .= "VALUES ";
  $sql .= "  ('$msgline', '$digest', 1) ";
  $sql .= "ON DUPLICATE KEY UPDATE total_count = total_count + 1";

  $sth = $dbh->prepare_cached($sql);
  $sth->execute();

I'm preparing the statement as cached based on the fact it will be the same statement that will execute several times. Therefore, eliminating having to contact the server on every perpare.

I know it's the $msgline that is causing issues in that if I pack $msgline into a readable hex text line, it stores without any errors. That would mean the SQL statement is getting messed up because of some of the characters within $msgline.

Use DBI quote method on $msgline.

        Racke

--
LinuXia Systems => http://www.linuxia.de/
Expert Interchange Consulting and System Administration
ICDEVGROUP => http://www.icdevgroup.org/
Interchange Development Team


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to