Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: Insert Row

by reneeb (Chaplain)
on Dec 08, 2006 at 08:07 UTC ( #588540=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Insert Row
in thread Insert Row

You should use quote_identifier instead of tr///.

$table = $dbh->quote_identifier($table);


Comment on Re^3: Insert Row
Select or Download Code
Re^4: Insert Row
by Rhandom (Curate) on Dec 10, 2006 at 07:12 UTC
    I most certainly agree. I never program in such a way that I am passing in arbitrary table names though and so I've never needed to look up the method that would quote it for me. Thankyou for pointing out the correct method.

    In all cases the name of the table could be validated before trying to use it in actual SQL - either by using "show tables" in MySQL or by "SELECT table_name FROM user_tables" in Oracle. Either way I would not be using the user supplied data in that portion of the SQL.

    my @a=qw(random brilliant braindead); print $a[rand(@a)];

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2014-10-25 09:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (142 votes), past polls