I use PERL and a form with a <text area> and CGI scripts to input text into a MySQL table. The script is something like this:

sub update { #!/usr/bin/perl -w use DBI; my ($dbh, $sth, $AccountID, $Input); $AccountID="$FORM{'AccountID'}"; $Input="$FROM{'Input'}"; $dbh = DBI->connect('dbi:mysql:membersdb','member','somepasswd') || di +e "cannot open"; $sql = qq`UPDATE memberinfo SET Input='$Input' WHERE AccountID='$Accou +ntID'`; $sth = $dbh->prepare($sql) or die "Cannot prepare: " . $dbh->errstr(); $sth->execute() or die "Cannot execute: " . $sth->errstr(); $sth->finish(); }
The text is input just fine as long as it doesn't contain single or double quotes. I know the quotation marks have to be escaped but have not been able to find a method to do that to a variable, i.e. $Input. Is there a simple way to do that with PERL? If so can someone point me to it or, better yet, provide the code I need in the above example. Thanks for any assistance!!


In reply to MySQL Not Accepting $Value That Contains Single or Double Quotes by Milti

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.