derekshull Posted October 6, 2012 Author Share Posted October 6, 2012 I'm getting this becasue its a date now...not an array correct? Link to comment https://forums.phpfreaks.com/topic/269177-help-with-reminder-script/page/2/#findComment-1383354 Share on other sites More sharing options...
Barand Posted October 6, 2012 Share Posted October 6, 2012 Don't use NOW() when comparing with a date value. NOW() contains a time element (so 2012-10-06 != 2012-10-06 22:35:40). Use CURDATE() instead. Link to comment https://forums.phpfreaks.com/topic/269177-help-with-reminder-script/page/2/#findComment-1383356 Share on other sites More sharing options...
Jessica Posted October 6, 2012 Share Posted October 6, 2012 Don't use NOW() when comparing with a date value. NOW() contains a time element (so 2012-10-06 != 2012-10-06 22:35:40). Use CURDATE() instead. Thanks. OP: See the link in my signature for your error. Link to comment https://forums.phpfreaks.com/topic/269177-help-with-reminder-script/page/2/#findComment-1383357 Share on other sites More sharing options...
derekshull Posted October 6, 2012 Author Share Posted October 6, 2012 I changed it to CURDATE() and it still throws off the error :-/ Link to comment https://forums.phpfreaks.com/topic/269177-help-with-reminder-script/page/2/#findComment-1383359 Share on other sites More sharing options...
derekshull Posted October 6, 2012 Author Share Posted October 6, 2012 I'm guessing you're stumped and thats why I was given the link. Link to comment https://forums.phpfreaks.com/topic/269177-help-with-reminder-script/page/2/#findComment-1383360 Share on other sites More sharing options...
Barand Posted October 6, 2012 Share Posted October 6, 2012 Have you changed your dates to type DATE, format 2012-10-06? The format you were using (06102012) is as much use as a chocolate teapot for date comparisons eg 07102011 > 06102012 Link to comment https://forums.phpfreaks.com/topic/269177-help-with-reminder-script/page/2/#findComment-1383363 Share on other sites More sharing options...
derekshull Posted October 6, 2012 Author Share Posted October 6, 2012 I actually figured out what was wrong. While it wasn't really where I was being led I stared at if for a few minutes and it came to me. Thanks for all the help! Link to comment https://forums.phpfreaks.com/topic/269177-help-with-reminder-script/page/2/#findComment-1383364 Share on other sites More sharing options...
Barand Posted October 6, 2012 Share Posted October 6, 2012 And the answer was......? Link to comment https://forums.phpfreaks.com/topic/269177-help-with-reminder-script/page/2/#findComment-1383366 Share on other sites More sharing options...
derekshull Posted October 6, 2012 Author Share Posted October 6, 2012 $query = 'SELECT * FROM needs WHERE completiondate = DATE_ADD(CURDATE(), INTERVAL 2 DAY)'; $result = mysql_query($query); while ($rows = mysql_fetch_array($result)) { mail ('[email protected]', 'Subject', 'Body'); } for starters there should have been an _ between DATE and SUB. But then DATE_SUB was wrong. I'm needing the script to see if its two days away and remind me two days in advance. So instead of DATE_SUB you need DATE_ADD. Jessica put me on the right path though. Thanks for teaching me Jessica. And thanks for your help Barand! Link to comment https://forums.phpfreaks.com/topic/269177-help-with-reminder-script/page/2/#findComment-1383367 Share on other sites More sharing options...
Barand Posted October 6, 2012 Share Posted October 6, 2012 I never bother with DATE_ADD or DATE_SUB. I find it much easier to use something like ... WHERE completiondate = CURDATE() + INTERVAL 2 DAY Link to comment https://forums.phpfreaks.com/topic/269177-help-with-reminder-script/page/2/#findComment-1383368 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.