[PHP] Just cant figure out how this could be happening...

2002-10-03 Thread Owen Parker

hi all

have a really simple query:

$twowksworth = mysql_query(SELECT updates.MODELCODE, updates.SETNO,
updates.FRPICNO, updates.TOPICNO, updates.CPOSTDATE, updates.ZIPFILENAME,
updates.TOTPICS, models.MODELNAME FROM updates LEFT JOIN models ON
updates.MODELCODE = models.MODELCODE WHERE updates.CPOSTDATE = (
CURDATE() - 14 )AND updates.CPOSTDATE = CURDATE() ORDER BY
updates.CPOSTDATE  ) ;

When this was originally written it worked like a charm.  I purposefully
let it 'run out' of data by not adding any more to the table.  each day for
two weeks the list resulting from this query got shorter as expected.  The
day after there was no data, it started listing the entire contents of the
table.  What the...

So i added a few weeks worth of data and now it correctly cuts off at
today's dat but it completely ignores the curdate() - 14 portion and lists
the entire table up to today's date.

this is so basic i cant figure it out.  besides, it used to work.  what
gives?  I'm really new to php and mysql, but until now felt i had made good
progress in the past couple
weeks.  just cant figure out how to troubleshoot this error due to lack of
experience and knowledge.

is there something really basic i am missing here?  any pointers would be
greatly appreciated!!

tia

owen






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




Re: [PHP] Just cant figure out how this could be happening...

2002-10-03 Thread Chris Wesley

SELECT CURDATE() - 14 ... this isn't doing what you think it's doing.

The CURDATE() function returns a string like 2002-10-03.
Subtracting 14 from that gets you 20020989 as a result from MySQL.
Pretty useless, right?  If that ever worked for you, it was a total
coincidence.

Try this instead:
  SELECT DATE_SUB( CURDATE(), INTERVAL 14 DAY )
That will get you the date from 14 days ago.

See the MySQL manual for descriptions of the functions.
I'm sure that the MySQL site has references to MySQL mailing lists too, to
help with MySQL questions.

g.luck,
~Chris

On Thu, 3 Oct 2002, Owen Parker wrote:

 hi all

 have a really simple query:

 $twowksworth = mysql_query(SELECT updates.MODELCODE, updates.SETNO,
 updates.FRPICNO, updates.TOPICNO, updates.CPOSTDATE, updates.ZIPFILENAME,
 updates.TOTPICS, models.MODELNAME FROM updates LEFT JOIN models ON
 updates.MODELCODE = models.MODELCODE WHERE updates.CPOSTDATE = (
 CURDATE() - 14 )AND updates.CPOSTDATE = CURDATE() ORDER BY
 updates.CPOSTDATE  ) ;

 When this was originally written it worked like a charm.  I purposefully
 let it 'run out' of data by not adding any more to the table.  each day for
 two weeks the list resulting from this query got shorter as expected.  The
 day after there was no data, it started listing the entire contents of the
 table.  What the...

 So i added a few weeks worth of data and now it correctly cuts off at
 today's dat but it completely ignores the curdate() - 14 portion and lists
 the entire table up to today's date.

 this is so basic i cant figure it out.  besides, it used to work.  what
 gives?  I'm really new to php and mysql, but until now felt i had made good
 progress in the past couple
 weeks.  just cant figure out how to troubleshoot this error due to lack of
 experience and knowledge.

 is there something really basic i am missing here?  any pointers would be
 greatly appreciated!!

 tia

 owen






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




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