Re: [PHP] problems in WHERE statment



On 5/23/07, Greg Donald <gdonald@xxxxxxxxx> wrote:

On 5/21/07, Mike Ryan <miker@xxxxxxxxxxxxxx> wrote:
> I am a newbie so please bear with me.
>
> 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

'$today' not $today



--
Greg Donald
http://destiney.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



You're also single-quoting your SQL query. When including a variable in
there, you should double-quote around the query string, and single-quote the
values you're seeking.

Example:

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

It looks like your PHP code was generated by phpMyAdmin.... I know it
outputs data like you supplied. Also, as a postscript, you should try not
to use table names that include a space. If at all possible, convert `job
listing` to `job_listing` with an underscore.

--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107


Relevant Pages

  • Re: Damn you, FEDEX! or Nikon D40 lost in Springfield, MO blackhole.
    ... the 2 mp Mavica he had been using with a Nikon D40. ... After shopping around, he got me to order one for him. ... The shipper had it insured, but from what I have read it could take weeks to sort this crap out. ... You may get your insurance from FedEx and a couple weeks later they find it and deliver it. ...
    (alt.photography)
  • Re: [PHP] array issues
    ... I think you ment ... are doing, but with only the query to look at, it's hard to tell... ... I have paste a sample record below; ... PHP General Mailing List ...
    (php.general)
  • Re: [PHP] db query not working
    ... I saw two people pointing two errors on the SQL insert statement which you would have found yourself had you put the 'or die' at the end of the query, ... $result = mysql_query ("SELECT DISTINCT company FROM view_log WHERE company!= ''"); ... It dumps the table fine, works the explode, outputs the string in the echo command the way I expect, but doesn't place the value in tmphitsmag table. ... PHP General Mailing List ...
    (php.general)
  • RE: [PHP] mysql update query
    ... populated from a monthly csv file supplied from an external source. ... Subject: mysql update query ... PHP General Mailing List ...
    (php.general)
  • Re: [PHP] need help to build a query
    ... you can do "explain $query" to see what MySQL estimates will ... PHP General Mailing List ... To unsubscribe, visit: http://www.php.net/unsub.php ...
    (php.general)