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 8975749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:57:32+00:00 2026-06-15T18:57:32+00:00

I am making a meeting room booking system in which there should be no

  • 0

I am making a meeting room booking system in which there should be no times within the start and end dates so in theory the validation should check for no dates/times within one start and end date time frame.

I have two tables, I can insert into it fine with both start and end dates so the only columns i am interested in at the moment are these

meetingrooms

|————————————|
|- bookingtime -|-bookingend-|

I understand the principle behind the sanity check and the check i can do in psudocode. Here is the code i have got so far –
>

p4a_db::singleton()->query("INSERT INTO meetingrooms(location_id, bookingtime, bookingend, merono_id)
                WHERE bookingtime < " . $date . " AND bookingend > " . $date . "
                OR
                bookingdate < " . $date . " AND bookingend > " . $dateend . "
                VALUES(?,?,?,?)",
                array($location, $date, $dateend, $merono));

I don’t want to insert data directly into the statement but until i understand how to do this i am stuck, so the question,

How do i perform a sanity check before the data is inserted so that i don’t get dates within booked times.

any help would be greatly appreciated.

  • 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-06-15T18:57:34+00:00Added an answer on June 15, 2026 at 6:57 pm

    after a long and intensive search, I have now got a working example of this method, along with a method of protecting against sql injection, here’s the code;

    if ($this->BookingValue == 1)
        {
            $sql = "SELECT COUNT(*) as num FROM meeting_room_bookings
                    WHERE
                    (
                    (? < start_at AND ? > start_at)
                    OR
                    (? > start_at AND ? < end_at)
                    )
                    AND
                    meeting_room_id = ?";
    
            $result = p4a_db::singleton()->fetchRow($sql, array($date, $date, $date, $dateend, $merono));
    
            if ( 0 == $result["num"] )
            {
    
             p4a_db::singleton()->query("INSERT INTO meeting_room_bookings (start_at, end_at, meeting_room_id)
                        VALUES
                        (?,?,?)", array($date, $dateend, $merono));
    
                return true;
            }       
            else
            {
             return false;
    

    There isn’t much to explain about this code, but in term of differences, (excluding the change in column names with the table) the query is now prepared before the value is set, then it is possible to use it in an if statement, thus allowing the validation to take place to filter results between different dates.

    along with this i have added validation to stop dates from other meeting rooms being included within the statement via the AND statement where the meeting room id is limeted to a single value.

    Although now, which will lead on to a separate question is another thrown error that comes from this statement, i know the insert is sound but something from this prepared statement causes the error:

    SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
    File: Pdo.php, Line: 234

    Although now i am looking into a error that is thrown from the prepared statement and will update this answer when there is a fix, thanks for the help.

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

Sidebar

Related Questions

I am making a booking system where users can make appointments with each other.
I'm looking at making a booking system and I need to display all the
Making an adobe flex ui in which data that is calculated must use proprietary
Making UML sequence diagram in VS 2010RC I've observed that there is no activation
Making websites that appear correctly in IE is a big problem. Is there any
We had a meeting this morning about how would should store our ID for
Making a left hand side menu for my website. Should I create a Unordered
Making a simple program which will generate a multiple choice form. I have an
Making a system with my group in school and got a problem figuring out
Making a simple plugin , which executes javascript when a page is loaded ,

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.