Re: MySQL & Perl: Using a Dynamic SELECT Statement
- From: Tad McClellan <tadmc@xxxxxxxxxxxxxx>
- Date: Thu, 15 Nov 2007 00:00:18 GMT
Jason Carlton <jwcarlton@xxxxxxxxx> wrote:
if ($check_username) {
if ($type eq "loose") {
$whereby1 = "WHERE username LIKE CONCAT('%',?,'%')";
}
else {
$whereby1 = "WHERE username=?";
}
my $sth = $dbh->prepare("SELECT id FROM posts " . $whereby1);
$sth->execute($search);
You're using variables without showing us what they contain. What's
in $search? The fact that you haven't shown it suggests you consider
it irrlevant, but since you don't know what's going wrong, you
shouldn't make that assumption.
In this case:
$check_username = true;
.... and what is the return value from the true() function then?
Or was that supposed to be a string?
(strings in Perl are delimited by quote characters.)
And here the block in which you declared this second $sth ends. At
this point, the second $sth also ceases to exist.
while (my ($this_id) = $sth->fetchrow_arrayref()) {
Now you are attempting to use a variable that doesn't exist.
This tells me that you're not using strict. Why? It prevents you
from making mistakes like this. It's also rude to ask us for help
before you ask the computer for help.
At least he wasn't sleep-deprived this time and blaming the resulting
mess on everybody else:
Message-ID: <1158029547.380968.166590@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
.
- References:
- MySQL & Perl: Using a Dynamic SELECT Statement
- From: Jason Carlton
- Re: MySQL & Perl: Using a Dynamic SELECT Statement
- From: Paul Lalli
- Re: MySQL & Perl: Using a Dynamic SELECT Statement
- From: Jason Carlton
- MySQL & Perl: Using a Dynamic SELECT Statement
- Prev by Date: Re: Back references
- Next by Date: Re: how to check whether the field is filled or empty in perl TK
- Previous by thread: Re: MySQL & Perl: Using a Dynamic SELECT Statement
- Next by thread: Command Line Arguments from a File
- Index(es):
Relevant Pages
|