Jump to content

Recommended Posts

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

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

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

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

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().

@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

@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()

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.