You should use placeholders.
(minor tweaks to fix typos..)$query1="(select Name from Customers where CustId=?)"; $query2="(select Name from Sales where SalesId=?)"; $sth1=$dbh->prepare($query1); $sth2=$dbh->prepare($query2); if ($x>10) { $sth1->execute($custid); } else { $sth2->execute($salesid); }
In reply to Re: Dynamic SQL
by bitingduck
in thread Dynamic SQL
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |