Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: MySQL Error

by Caillte (Friar)
on Nov 20, 2001 at 21:29 UTC ( [id://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;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://126555]
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: (3)
As of 2024-03-28 15:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found