Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: SQL Injection myths under DBI

by dbwiz (Curate)
on Apr 12, 2005 at 07:32 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-25 15:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found