Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7502705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:57:45+00:00 2026-05-29T20:57:45+00:00

So I am working on a client website and it includes an event calendar

  • 0

So I am working on a client website and it includes an event calendar as its main focus. The calendar functions: you can insert events with a date,start_time,end_time. and then its displayed on the calendar and you get the picture. The problem I am having is conflicts between current events and ones people are trying to book as new events. I know logically I will need to check if its:

  1. between the event
  2. during the event but starting before it
  3. during the event but starting during it and ending afterwards.

The sql query I made up to start is this(it doesnt work):

$check_date_time = "SELECT `event_date`, `start_time`, `end_time` FROM `calendar_events` WHERE
 '.$_POST['event_date'].' = event_date AND
'.$_POST['start_time'].' BETWEEN `start_time` AND `end_time` 
AND '.$_POST['start_time'].' < `start_time` AND '.$_POST['end_time'].' < `end_time` 
|| '.$_POST['start_time'].' > `start_time` AND '.$_POST['end_time'].' < `end_time`';
$result = mysql_query($check_date_time, $mysql)
            or die(mysql_error());

Any help would be appreciated, I dont know if I am writing the query wrong or if the database is setup wrong.

Thanks, Andrew

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T20:57:46+00:00Added an answer on May 29, 2026 at 8:57 pm

    It looks to me like you’re storing the dates and times in a text/varchar field and attempting to use the BETWEEN operator which only works on date/numerical fields.

    Run this query: SHOW CREATE TABLE calendar_events;

    And post back the results for us so we can see your table structure.

    Also I should point out that putting $_POST data directly into a SQL query is a very very veeeeerrrrry bad idea under any circumstance. That’s how you expose yourself to SQL injection attacks and get your entire database compromised.

    You should use a helper class or at least calling mysql_escape_string or using the escape method on mysqli around each data element. Also, make sure you wrap your parameters in the query in single quotes. You should also wrap your table/column names in backticks (`). Even though they are technically optional, it does help when reading queries and it avoids the errors caused by data/fieldname collision.

    For example if I posted “event_date” as the data for $_POST[‘event_date’] MySQL would get confused since it would interpret that part of the query as event_date = event_date which of course will always be true.

    With single quotes and backticks properly used: ‘event_date’ = event_date Now MySQL knows that the first occurrence is telling it to look for cases where the value of event_date is present in the event_date column of the table.

    At any rate, post back the table structure, put your single/backtick quotes in place, and I think it’ll be much easier for us to help you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a website where users can sell tickets to their events. Tickets
We are working on a website for a client that (for once) is expected
I'm currently working on a website for a client and I'm getting a strange
We are working on a website which will provide the client access to a
A client has sent me a Flash CS3 website template she was working on.
currently i am working on a website and the client requires page curl effect
I am working on a multisite for a client for a skateboarding website. So
I'm working on a website were a client wants to display a random testimonials
I have a working website on a pre-production server, all functions are responding correctly.
I'm working on a website for a client, in PHP/MySQL. They are a publisher,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.