Re: problems in WHERE statment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Em Segunda 21 Maio 2007 16:46, Mike Ryan escreveu:
> I get this error message when I try to run a query
>
> Connected successfullyCould not successfully run query () from DB: Unknown
> column '$today' in 'where clause'
>
> this is the query command
>  $query = 'SELECT *
> FROM `job listing`
> WHERE open >=$today
> LIMIT 0 , 30 ';
>
> I have assigned $today this way $today=date("Y-m-d");
>
> Can you tell me what I did wrong??
>

Sure! =)

You must scape your PHP variables in any SQL query...

Try this:

$query="SELECT *
FROM `joblisting`
WHERE open >= '$today'
LIMIT 0,30";

HTH
-- 
Davi Vidal
davividal@xxxxxxxxxxxxxxxx
davividal@xxxxxxxxx
--
"Religion, ideology, resources, land,
spite, love or "just because"...
No matter how pathetic the reason,
it's enough to start a war. "

Attachment: pgpZujKqi9Dnv.pgp
Description: PGP signature


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux