Login | Register | FAQ
Anonymous

CURDATE() is not working

+ Post a reply

3 posts Page 1 of 1


CURDATE() is not working

by PF2G » Mon Jul 09, 2012 12:00 pm

Hi,

I'm trying to do a list of news, but i only want today's news and news from the past what i don't want is future news(tomorrow,...).

So i'm using CURDATE -> if date <= CURDATE the news appear, but future news appear anyway, can you help me, plz?

Code: Select all
$curdate = date("d-m-Y");

$row_noticias = getRows("SELECT n.id, n.data, str_to_date(n.data, '%d/%m/%Y') AS date, nl.id_noticia, nl.titulo, nl.descricao, nl.resumo
FROM `noticias` as n, `noticias_lang` as nl
WHERE n.id = nl.id_noticia AND n.data < $curdate
nl.lang='$current_lang' AND n.visivel=1 AND nl.visivel=1
ORDER BY date DESC LIMIT 1");


EDIT: i changed the code, and i did an echo of $curdate and it's alright, but when i have like this:
Code: Select all
n.data < $curdate


it gives me error:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\www.af-reabilitacao.com\common.php on line 59


Thank you,
PF2G
User avatar

PF2G

  • Posts: 3
  • Joined: Fri May 18, 2012 11:15 am

Re: CURDATE() is not working

by atik » Tue Jul 10, 2012 3:55 am

Hi,
How the "n.data" field is saved in your table? What is the data type of this field? Can you give me a sample record stored in that field?
User avatar

atik

  • Posts: 472
  • Joined: Mon Oct 17, 2011 4:55 pm

Re: CURDATE() is not working

by PF2G » Mon Jul 16, 2012 3:19 pm

Hi,

Firstable thank you for the reply.

Burt i already solved the problem...

Thnak you,
PF2G
User avatar

PF2G

  • Posts: 3
  • Joined: Fri May 18, 2012 11:15 am


+ Post a reply

Page 1 of 1