I'm working on a large database-driven web site, one of whose components is a hit tracker that will update a table each time a link gets clicked.
I've set the whole thing up with DBI/MySQL, and most of it works great. However, the actual update query to post the new number of hits, the IP they're from, etc., is frustrating me greatly.
To properly fit things in the database, I'm first making up a string that contains my SQL statement. The string ends up looking like this:
UPADTE urls SET hits = "?", unixdate = "?", ip1 = "?" WHERE id = ?
After filling up an array with the appropriate values -- and yes, I'm checking that the values are in the right order, and of the right number -- I call this code:
$sth = $dbh->prepare($stmt); #$stmt is, of course, my string
$sth->execute(@values);
my $tmp = $sth->rows;
print "Rows Affected: $rows"; #Just to see if it worked.
Amazingly enough, nothing is printing (I'd earlier printed out my http headers and other data, so it's not that I can't print altogether) at all on this. Meanwhile, my database does not reflect the update at all.
Is there any good reason, based on this code, that my query wouldn't work? I'll be happy to provide more info and more surrounding code if it helps.
Alex Kirk
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.