SPUG: BD::mysql::st execute failed:

tcaine at cac.washington.edu tcaine at cac.washington.edu
Tue Sep 19 10:31:46 PDT 2006


One of your variables has a ' in it.  Use placeholders and bind values. 
Try reading the perldoc for DBI, particularly the "Placeholders and Bind 
Values" section.

On Tue, 19 Sep 2006, luis medrano wrote:

> Hey List,
>
> I have a problem I'm trying to run this piece of code inserting values to a
> row in a mysql database where "post_content" is type longtext:
>
>       my $sth1=$dbh->prepare("INSERT INTO wp_posts(post_author, post_date,
> post_date_gmt, p
> ost_content,post_title, post_status, comment_status, ping_status,post_name,
> post_modified, po
> st_modified_gmt,guid)
>
> VALUES('$post_author','$post_date','$post_date_gmt','@post_content','$post_title','$p
> ost_status','$comment_status','$ping_status','$post_name','$post_modified','$post_modified_gm
> t','$guid')")  or die; # "Couldnt prepare statement: " . dbh->errstr;
>       my $rv1 = $sth1->execute();
>
> But I'm trying to insert text file to post_content and showing this error
> when I ran the script:
>
>
> BD::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 't know what a CHM file isNULL Just think of the Help program that
> comes up when ' at line 2 at posting.pl line 75.
>
>
> But if replace the text file for a string on @post_content I have no error
> running the script. Any ideas or suggestions of what I'm doing wrong?
>
> Thanks,
> Luis
>


More information about the spug-list mailing list