Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: MySQL Error

by Caillte (Friar)
on Nov 20, 2001 at 21:29 UTC ( #126555=note: print w/ replies, xml ) Need Help??


in reply to Re: MySQL Error
in thread MySQL Error

This isn't perfect as you do not quote $status. It is often better to let DBI do that for you:

my $arg; if(defined $status) { $statement = 'SELECT COUNT(*) FROM name WHERE status=?;'; $arg = $status; } else { $statement = 'SELECT COUNT(*) FROM name WHERE age=?;'; $arg=4; } $sth = $dbh->prepare($statement) or die "Cannot Prepare $DBI::errstr"; $sth->execute($arg) or die "Cannot execute $DBI::errstr";

Calling the statement this way makes sure the data is properly quoted.

$japh->{'Caillte'} = $me;


Comment on Re: Re: MySQL Error
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2014-12-25 00:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls