in reply to single error with a dbh prepare

Check your quotes. You are using double quotes within a double-quoted string - and that's never going to work. I recommend switching to qq().

Also, you need to use the concaternation operator and more quotes to include the parameter value in the string.

Oh. And your order clause isn't right.

$sth = $dbh->prepare(qq( SELECT * FROM $pictures_table WHERE stats="2" AND poster_name = ') . param('name') . qq(' ORDER BY poster_name ASC));

Actually, it might be easier to use a placeholder to insert the parameter. That way you don't need to worry about the quoting.

$sth = $dbh->prepare(qq( SELECT * FROM $pictures_table WHERE stats="2" AND poster_name = ? ORDER BY poster_name ASC)); $sth->execute(param('name'));
--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re^2: single error with a dbh prepare
by davidrw (Prior) on May 17, 2006 at 15:27 UTC
    does mysql accept dblquotes for stats="2" or does it have to be single stats='2' ? Might as well bind that anyways w/ stats = ? and $sth->execute(2, param('name')) so there's no quoting at all..

      does mysql accept dblquotes for stats="2" or does it have to be single stats='2'?

      Yes, it accepts both.

      Oh, btw, just go to http://www.mysql.com/ and download any stable version and try it out, works on most platforms, is free of charge (in that circumstance) and easy to install (5-10 minutes) and get up to speed.

      Cheers, Sören