On Mon, 3 Jul 2006, Stefan Hornburg wrote:
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.
I'm still a little green with this and had to dig just a wee little bit on
the quote method. I've never used the q and qq before. It is working now!
Through having to dig just a little, I've also found a more efficient way
of doing a loop in the code. Thanks!
--
"This message was sent using 100% recycled electrons."
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]