Re: [PHP] problems in WHERE statment



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: pgp8028epSL7p.pgp
Description: PGP signature



Relevant Pages

  • RE: Any good T-SQL quick reference recommended?
    ... The full syntax of the SELECT ... SELECT Clause ... Specifies the columns to be returned by the query. ... Specifies that duplicate rows can appear in the result set. ...
    (microsoft.public.sqlserver.programming)
  • RE: Xlocking with a select statement
    ... named query expression, order clause, update clause, lock option ... A result table or the underlying base tables are updateable if the query ... A lock can be requested for the ...
    (microsoft.public.sqlserver.programming)
  • Re: VB-ADO-SQL Server : SQL Server performs logins after some queries
    ... If you have some joins or WHERE clause in your statement, ... Also try to minimize selection of the records using WHERE ... Incase of actual action query, ... >> of queries and I've concluded that in case of an internet conection the ...
    (microsoft.public.vb.database.ado)
  • Re: update query: still having problems
    ... "Michel Walsh" wrote: ... From the User Interface, in the toolbar, or the menu, when you edit a query, ... If this is what you want, fine, else, add a WHERE clause to limit ... SELECT Department.*, sheet1.* ...
    (microsoft.public.access.queries)
  • Re: update query: still having problems
    ... "Michel Walsh" wrote: ... you should find a button that allows you to change the query "type". ... If this is what you want, fine, else, add a WHERE clause to ... SELECT Department.*, sheet1.* ...
    (microsoft.public.access.queries)