Re: MySQL & Perl: Using a Dynamic SELECT Statement



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/"
.



Relevant Pages

  • Re: Guitar String Not Staying In Tune
    ... There are only a few things that cause a slipping string: loose windings ... on the post, the ball end coming loose, or a bad/loose gear. ... If this happens, change the string. ... > My Fender Strat had been staying perfectly in tune for weeks at a time. ...
    (alt.guitar)
  • Re: Guitar String Not Staying In Tune
    ... If the tuning machines are okay,no loose screws etc. then I would ... then do the appropriate stretching and tune up and see ... but change the first string first to see if that helps. ... >> windings on the post, the ball end coming loose, or a bad/loose gear. ...
    (alt.guitar)
  • Re: Lets Be Shut Of It.....
    ... wasn't the last threadorama also started with a post saying "let's ... show restraint and stop having long silly flaming threads"? ... As long as it's not showing, ... If it can be covered by a G string, I don't think we should worry about it. ...
    (rec.music.makers.guitar.acoustic)
  • Re: 0 == false == ""
    ... This makes no sense as a typeof operation evaluates to a string ... If you used a loose comparison on an empty string, ... programmer is simply saying "compare these things in a strict manner," ...
    (comp.lang.javascript)
  • Re: Compile error: Block If without If
    ... CaseNumber, OfficerNumber, and Incident are showing up in the string. ... Regarding the record source table, I have lost track of what you are trying ...
    (microsoft.public.access.formscoding)