The primary cause of your problem is that all the other values you are setting are numbers, so the SQL parser takes them without quotes. Only
$updy is a character string - and you're passing it in without the quotes.
If you changed the code to say:
$dbh->do("UPDATE INV SET SOLD=\"$updy\" WHERE CODE==$CODE");
it would work.
But don't do that.
Instead, learn to use placeholders. It is true that they make you type more, but they take care of quoting problems like the one above:
$sth=$dbh->prepare("UPDATE INV SET SOLD=? WHERE CODE==?");
$sth->execute($updy,$CODE); # Why is that var all UPcase, BTW?
If you are performing this stuff in a loop, you can move the
prepare stage out of the loop, and speed it up.
Finaly, I don't know if your SQL database doesn't allow multiple updates in a single statement (most do), but if you're having that much trouble with writing SQL, you really should take a look at an abstraction layer like Class::DBI, which lets you treat database tables and rows as objects, and manipulate them more easily.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.