Ray Hunter wrote:
On Tue, 2004-05-04 at 19:18, msa wrote:

$query_rsENews = 'SELECT * FROM NewsArchive WHERE YEAR(datePublished) = ' .
YEAR('NOW'()) . ' AND MONTH(datePublished) = ' . MONTH('NOW'()) . ' ORDER BY
sortBy DESC';


this is supposed to return only the records that have the current month and year in the datePublished record.

got this error:
Fatal error: Call to undefined function: year()



You sure you did not mean $dataPublished?

I think datePublished is his columnName?

But also:
Assuming mySQL (I can't find your original post?):
+++This is all wrong:
mysql> SELECT YEAR('NOW'());
ERROR 1064: 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 '())' at line 1


+++This is even worse, really:
mysql> SELECT YEAR('NOW()');
+---------------+
| YEAR('NOW()') |
+---------------+
|          NULL |
+---------------+
1 row in set (0.00 sec)

+++This is what you want:
mysql> SELECT YEAR(NOW());
+-------------+
| YEAR(NOW()) |
+-------------+
|        2004 |
+-------------+
1 row in set (0.00 sec)



So I'd guess at your syntax being:
$query_rsENews = <<<_SQL
SELECT *
  FROM NewsArchive
 WHERE YEAR(datePublished)  = YEAR(NOW())
   AND MONTH(datePublished) = MONTH(NOW())
 ORDER BY sortBy DESC
_SQL;

HTH

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



Reply via email to