Look at the actual strings you are sending to $dbh->do. If the user has a single-quote in a field (like dated, issuedby, etc), the SQL string will be bad.
my $Str = "Insert into City_Policies (ID, DATE_CREATED, ISSEDBY, SUBJE +CT) values ('$policynumber', '$DATE_CR', '$ISSUEDBY', '$newsubject')"; warn $Str; $dbh->do($Str) or print "I died";
This may be a good reason to go ahead and build statement handles and use placeholders. DBI will handle embedded quotes for you.

BTW, may I suggest a stylistic change? ;-)

my $POLICY1 = ""; my $DATE_CR = ""; my $POLICY2 = ""; my $POLICY3 = ""; my $POLICY4 = ""; my $POLICY5 = ""; my $POLICY6 = ""; my $ISSUEDBY = ""; my $SUBJECT =""; my $PURPOSE = ""; $POLICY1 =~s/<br>/\n/g; $POLICY2 =~s/<br>/\n/g; $POLICY3 =~s/<br>/\n/g; $POLICY4 =~s/<br>/\n/g; $POLICY5 =~s/<br>/\n/g; $POLICY6 =~s/<br>/\n/g; $POLICY1 =~s/<BR>/\n/g; $POLICY2 =~s/<BR>/\n/g; $POLICY3 =~s/<BR>/\n/g; $POLICY4 =~s/<BR>/\n/g; $POLICY5 =~s/<BR>/\n/g; $POLICY6 =~s/<BR>/\n/g;
can be more succinctly written as:
my ($IDNUM, $ISSUEDBY, $DATE_CR, $SUBJECT, $PURPOSE, $POLICY1, $POLICY2, $POLICY3, $POLICY4, $POLICY5, $POLICY6) = $sth->fetchrow_array; $_ ||= '' for ($DATE_CR, $ISSUEDBY, $SUBJECT, $PURPOSE); $_ ||= '', s/<br>/\n/ig for ($POLICY1, $POLICY2, $POLICY3, $POLICY4, $POLICY5, $POLICY6) +;
Far fewer lines, and you get to use the cool ||= and postfix for operators! :-)

Russ
Brainbench 'Most Valuable Professional' for Perl


In reply to Re: A seeming random error. by Russ
in thread A seeming random error. by BigJoe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.