in reply to MySQL question
What almut is talking about:
#instead of: $sql = qq { insert into my_table (update_1) values ('$sometext') }; $sth = $dbh->prepare($sql); $sth->execute(); #use placeholders: $sql = qq { insert into my_table (update_1) values (?) }; $sth = $dbh->prepare($sql); $sth->execute($sometext);
First, it will do all the escaping for you, second, will protect your script against injection attacks.
BTW, if you are going to do a lot of this, you should look at a framework like CGI::Application that does a lot of the heavy lifting for you.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: MySQL question
by Dranzaz (Sexton) on Nov 28, 2008 at 14:34 UTC | |
by lostjimmy (Chaplain) on Nov 28, 2008 at 15:07 UTC |