Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: SQL Injection myths under DBI

by dbwiz (Curate)
on Apr 12, 2005 at 07:32 UTC ( #446884=note: print w/replies, xml ) Need Help??

in reply to SQL Injection myths under DBI?

I second tilly's opinion that what you are saying is plainly wrong, and here are a few points that you shoudl consider:

  • my $sth = $dbh->prepare ("select username, password from users where sid='?';" )

    That is simply wrong.
    Placeholders must not be quoted. A placeholder means "leave it to the database driver to deal with any quoting business."

  • this solution will cost you a hell of a work if you like the simplicity of the do() method and have used it all over your code
    What's wrong with using the do() method with placeholders?
    $dbh->do("INSERT INTO table (id, name) values (?, ?)", undef, $id, $na +me);
  • But what I could conclude, after a lot of thinking and, most of all, after testing all the supposedly harmfull examples in my little script, is that the only problem is the single quote
    That depends on the database you are using, and you should not be concerned about this matter, if you care to use the $dbh->quote method, which you should go and read in the docs.

The bottom line: I am afraid you don't know what you are talking about. Please read the docs more carefully.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://446884]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2023-09-26 06:37 GMT
Find Nodes?
    Voting Booth?

    No recent polls found