debecc Posted June 23, 2009 Share Posted June 23, 2009 Hello, I have created a schedule table of events and want to just show events on my page that occur with todays date and any future dates. My sql instruction is to call `date` >= NOW() . It works on my testing server on my computer but when I upload to the web server it won't show an event if it is today's date only the next date. Web server is PHP 5.29 and mysql version 5.1.30. Any ideas would be appreciated Thanks Deb Quote Link to comment https://forums.phpfreaks.com/topic/163372-solved-schedule-to-show-todays-event-and-future-events/ Share on other sites More sharing options...
MadTechie Posted June 23, 2009 Share Posted June 23, 2009 Run this SELECT NOW() as today on both servers this will give you the time, your probably find the times are different Quote Link to comment https://forums.phpfreaks.com/topic/163372-solved-schedule-to-show-todays-event-and-future-events/#findComment-861990 Share on other sites More sharing options...
debecc Posted June 23, 2009 Author Share Posted June 23, 2009 Thanks MadTechie, There is an hours time difference between servers but the day is the same. I can't figure it out. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/163372-solved-schedule-to-show-todays-event-and-future-events/#findComment-862125 Share on other sites More sharing options...
debecc Posted June 23, 2009 Author Share Posted June 23, 2009 Code: mysql_select_db($database_Softball_league, $Softball_league); $query_schedule_home = "SELECT DATE_FORMAT(schedule.date, '%c/%e/%y') AS date, schedule.location_id, schedule.`time`, location.location_id, location.location_name AS name FROM schedule, location WHERE schedule.`date` >= NOW() AND location.location_id = schedule.location_id ORDER BY schedule.`date` I am far from a php guru but this has worked for me at other times ???? Thanks for any help Quote Link to comment https://forums.phpfreaks.com/topic/163372-solved-schedule-to-show-todays-event-and-future-events/#findComment-862133 Share on other sites More sharing options...
MadTechie Posted June 23, 2009 Share Posted June 23, 2009 This is one of those questions we we need more info.. basically your need to check where the problem is.. check the data in the database or truncate the data and test it, you say is not displaying things but are the dates correct ? etc Quote Link to comment https://forums.phpfreaks.com/topic/163372-solved-schedule-to-show-todays-event-and-future-events/#findComment-862241 Share on other sites More sharing options...
debecc Posted June 23, 2009 Author Share Posted June 23, 2009 Thanks for the reply. The dates and location are showing, but only FUTURE dates not the date and location if the event is today. For example. If I had one event for today (6/23/09) and another for friday(6/26/09), the only event to show would be fridays event not todays. Basically I would like the event to show for today so that if someone goes to the site today they can see that there would be an event happening today. I hope that makes sense. :-\ Thank you Quote Link to comment https://forums.phpfreaks.com/topic/163372-solved-schedule-to-show-todays-event-and-future-events/#findComment-862249 Share on other sites More sharing options...
J.Daniels Posted June 23, 2009 Share Posted June 23, 2009 I believe you need to check the value of date. NOW() returns the current date and time. If the value of date only holds the date, I'm not sure if the compare will fail as date might refer to 12:00 am, which would be before NOW(). Maybe you can try to compare date to CURDATE(). Quote Link to comment https://forums.phpfreaks.com/topic/163372-solved-schedule-to-show-todays-event-and-future-events/#findComment-862276 Share on other sites More sharing options...
MadTechie Posted June 24, 2009 Share Posted June 24, 2009 @J.Daniels: Now() has been checked (see previous posts) However I agree that using CURDATE(), instead of NOW() maybe a good idea, but any schedule after the current time will stay in the list! @debecc Okay the main part of the query is this WHERE schedule.`date` >= NOW() Now, this should be working, but that assumes the date field is a timestamp, if its a date field then change NOW() to CURDATE() or the date field to a timestamp, Also how are you inserting the record, the correct way should be using NOW() as well, and last but not least, any records created and outside of the current server may not work on the new server so re-create them, if this the new ones work we can look at updating the old ones Quote Link to comment https://forums.phpfreaks.com/topic/163372-solved-schedule-to-show-todays-event-and-future-events/#findComment-862357 Share on other sites More sharing options...
J.Daniels Posted June 24, 2009 Share Posted June 24, 2009 @J.Daniels: Now() has been checked (see previous posts) However I agree that using CURDATE(), instead of NOW() maybe a good idea, but any schedule after the current time will stay in the list! @debecc Okay the main part of the query is this WHERE schedule.`date` >= NOW() Now, this should be working, but that assumes the date field is a timestamp, if its a date field then change NOW() to CURDATE() or the date field to a timestamp, Also how are you inserting the record, the correct way should be using NOW() as well, and last but not least, any records created and outside of the current server may not work on the new server so re-create them, if this the new ones work we can look at updating the old ones I was actually referring to the date field and the value type stored there. If date is a date field and it is the current day, it will evaluate to less than NOW() Quote Link to comment https://forums.phpfreaks.com/topic/163372-solved-schedule-to-show-todays-event-and-future-events/#findComment-862363 Share on other sites More sharing options...
MadTechie Posted June 24, 2009 Share Posted June 24, 2009 You can't have a field of a "NOW()" type! you can have a timestamp field, (which i refered to in my previous post) in any case if you search using NOW() or CURDATE() on a date field on will reveal the same results, ie NOW() would return something like this 2009-06-24 01:28:11 But CURDATE() would return something like this 2009-06-24 as would DATE(NOW()) return 2009-06-24 Quote Link to comment https://forums.phpfreaks.com/topic/163372-solved-schedule-to-show-todays-event-and-future-events/#findComment-862371 Share on other sites More sharing options...
debecc Posted June 24, 2009 Author Share Posted June 24, 2009 THANK YOU THANK YOU. I love this forum. CURDATE() worked. So basically if i use just value date then use CURDATE() but if i use value timestamp use NOW(). thanks everyone for your replies and help. Quote Link to comment https://forums.phpfreaks.com/topic/163372-solved-schedule-to-show-todays-event-and-future-events/#findComment-862648 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.