"Msa" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > 'SELECT * FROM table WHERE YEAR(date) = ' . date('Y') . ' AND MONTH(date) > = > > ' . date('m') . ' ORDER BY SORT DESC' > > > > What column type is your date column of? I know that the above statement > > works with the MySQL date (YYYY-MM-DD) and datetime column types. > > > > Regards, Torsten > > > > > > > > does this help? > > My date format is as above....I am getting the following error message: > > You have an error in your SQL syntax. Check the manual that corresponds to > your MySQL server version for the right syntax to use near 'Y') . ' AND > MONTH(date) = ' . date('m') . ' ORDER BY sort DESC' > > > I changed your code to fit my table name and "sort" to be lower case, as it > is in the database: > > "SELECT * FROM NewsArchive WHERE YEAR(date) = ' . date('Y') . ' AND > MONTH(date) =' . date('m') . ' ORDER BY sort DESC";
Sorry, my fault. Of course you have to assign this construct to a variable because PHP has to interpret the two date calls: $query = 'SELECT * FROM NewsArchive WHERE YEAR(date) = ' . date('Y') . ' AND MONTH(date) = ' . date('m') . ' ORDER BY sort DESC'; If you echo out $query it should look like: SELECT * FROM NewsArchive WHERE YEAR(date) = 2004 AND MONTH(date) = 05 ORDER BY sort DESC Use $query now in your mysql query command (probably mysql_query()) Hope this works, Torsten > > any ideas? > > thanks again!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php