i hate being a newb ...

i'm trying to display data from the db, but only if the date in the field 'end_date' is equal to or greater than today's date. i'm not concerned with server vs local time since i'm only dealing with US timeframes.

this is what i've tried:

$result=mysql_query("SELECT title, location, sponsor, description, begin_date, end_date, contact_name, contact_phone, link FROM {$table} WHERE end_date >= \'2008-12-16\' ORDER BY begin_date ASC" );
if (!$result) {
die("Query to show fields from table failed");
}

this worked yesterday, but not today - dunno why. today i get the mssage "query to show fields from table failed". but even if it worked today, i'd have to change the code everyday to match today's date.

i've tried defining $currentdate and using that as a variable in the WHERE clause but can't get it to work either.

so how does one go about doing this?

thanks for any/all help.

    Does the query fail? If so, what is the exactly MySQL error message?

    Also, why are the single quotes around the date escaped?

      it worked as written yesterday, but today i get the error "query to show fields from table failed"

      they are escaped as copied from phpmyadmin which created that string of code for me.
      i just removed them and now it works again, so that's good (weird, but good).

      but how do i get a dynamic current date in the WHERE clause?

        i'm too newb to understand what you mean.
        use a variable defined as curdate? or use curdate as the variable in the WHERE?

        sorry ...

          No variables involved; CURDATE() is a MySQL function.

          So... get rid of the quotes and the date value and just use CURDATE() there instead.

            AHA!!

            thanks so much. i guess i need a different php/mysql book, the one i have doesn't mention anything of the sort.

              Write a Reply...