my $query = "UPDATE staff SET password=$FORM{'newpassword'} WHERE $FORM={'name'} eq $ +record{'login'}";

Are you really sure you want "WHERE $FORM={'name'}" in your query? You use $FORM as a hash, and then use it in scalar context - so your query would get passed to your DB as: "... WHERE HASH(0x013221)={'name'}", or some other garbled mess.

I think you probably want "... WHERE name=$record{'login'}", or, making things simpler (and safer), using placeholders (if your dbh supports it) such as '... WHERE name=?'

Update: just one other quick thought - if your input is coming from a CGI form, as your $FORM variable indicates, you should be using the CGI.pm module. It'll save you a lot of headaches. :)

Update (again): just looking things over now, $FORM wouldn't print HASH(blahblah) - it wouldn't print anything. Once again, I'd forgotten that you can have $FORM and @FORM and %FORM and sub FORM{}, all at the same time. 'use strict' is good for finding your type of error, btw.


In reply to Re: Perl MSAccess SQL UPDATE by glivings
in thread Perl MSAccess SQL UPDATE by ozzie

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.