my $stmt= "SELECT * FROM users WHERE $searchfield = ? ORDER BY ? ASC"; my $sth = $dbh->prepare($stmt); $sth->execute($searchterm, $searchfield);
I guess you are referring to the ORDER BY ?.That would be prepared as ORDER BY 'lastname' meaning, "order by the word lastname", not the value of a column named lastname. You can prove this by trying
$sth->execute($searchterm, 'rubbish');You may 'think' it is working since you are only retrieving one record. See single-quotes-in-mysql-order-by-clause
pojIn reply to Re^9: CGI Action call
by poj
in thread CGI Action call
by tultalk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |