Re: Variable in Select statement?
On Mon, 01 Oct 2007 10:50:53 +0200, GarryJones <morack@algonet.se> wrote:
> I am writing a mysql select statement in php and I would like to
> include a variable in it but cant grasp the syntax.
>
> // Example
>
> What I want to do
>
> if ($forma == "mot" ) {
> $fishnet = "(1,2,3,4)";
> } else {
> $fishnet = "(3,4,7)";
> }
>
> $ml_collect='SELECT * FROM ml_lopp WHERE ml_lopp.sank IN $fishnet
> ORDER BY date1, ml_lopp.loppnum';
Change the single to double quotes. If you'd have echo()ed your query
before sending it to MySQL you would have spotted the error instantly.
--
Rik Wasmus
|