in reply to Escaping then un-escaping an apostrophe
Use placeholders instead.$SQL = "UPDATE $regtable SET favorites='$favorites' WHERE ID='$ID'";
my $sth = $dbh->prepare(qq{UPDATE $regtable SET favorites=? WHERE ID=? +}); $sth->execute($favorites, $ID) or die $dbh->errstr;
That way the escaping is done for you, and you avoid sql injection attacks.
Also, I advise you to use strict and use warnings. It appears that you're relying on global variables instead of passing parameters to your subs. This is very bad practice.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Escaping then un-escaping an apostrophe
by htmanning (Friar) on Mar 10, 2011 at 20:53 UTC | |
by wind (Priest) on Mar 10, 2011 at 21:09 UTC | |
by Anonymous Monk on Mar 10, 2011 at 21:07 UTC |