We could not add your event...

Help
2009-03-25
2013-05-23
  • I have seen this question posted before, but no answer was forthcoming. When scheduling the inspection the error message “We could not add your event. Please check your information and try again. ” I have checked my installation and checked all of my permissions. I am able to add users, change passwords and even check the availability, but I cannot save an appointment. Can somebody please point me in the right direction?

    Michael Leavitt
    Orem, Utah
    Michael@TheHomeInspector.com
    www.TheHomeInspector.com

     
    • JVB
      JVB
      2009-03-25

      Line 171 of add_event.php is returning FALSE.

      ->        if (!empty($add_event_id)){   // Line 171
              ...
              }else{
              ...

      Suggests an error with the input...

       
      • JVB
        JVB
        2009-03-25

        from the IF statement, $add_event_id is empty. 

        My next question would be why is $add_event_id empty?

         
        • Thanks for your continued help....

          Is there something on the page that is configurable that I should have done? I have done nothing to the add_events.php page other than upload the original file. Is there something that I failed to configure correctly on the initial application_top.php page?

          Michael Leavitt

           
          • JVB
            JVB
            2009-03-25

            Is this section configured?  its near the botttom of application_top.php

              $location_db_name = array (
                        'loc1' => 'event_id_location_1',
                        'loc2' => 'event_id_location_2',
                        'loc3' => 'event_id_location_3',   
                        );
              // Associative Display Array (key => display_text)
              $location_display = array (
                        'loc1' => '001 1029 (Van-Old)',
                        'loc2' => '003 9662 (Wagon)',
                        'loc3' => '700 1520 (Van-New)',       
                        );
              // Default Location Name Index
              define('DEFAULT_LOCATION_NAME', 'loc1');

            These two arrays map the location names as displayed on the web to your database columns event_id_location_1,2,3...

             
            • Yes. I even added a 4th event in the database and all of that looks correct.

              I am working on an online cave access reservation system that needs 4 6 hour reservation slots each day. This script looked like it could be modified to let the 4 locations be the 4 appointment slots. I have done nothing more to the script so far than to add another location in the database. I wanted to get it to work stock with the 4 locations and then I would tackle the obstacle of keeping the date selections but eliminating the every 15 minute time choices.

              If you know of a better reservation script that would allow for online reservations with 4 different overlapping time slots each day, then please direct me appropriately.

              Here is the portion of the code that you inquired about...

              // Associative DB Field Naming Array (key => db_field)
                $location_db_name = array (
                          'loc1' => 'event_id_location_1',
                          'loc2' => 'event_id_location_2',
                          'loc3' => 'event_id_location_3',
                          'loc4' => 'event_id_location_4',
                          );
                // Associative Display Array (key => display_text)
                $location_display = array (
                          'loc1' => 'AM #1 7AM-2:00PM',
                          'loc2' => 'AM #2 7:30AM-2:30PM',
                          'loc3' => 'PM #1 3:00PM-9:00PM',
                          'loc4' => 'PM #2 3:30PM-9:30PM',
                          );

               
              • JVB
                JVB
                2009-03-25

                Something to think about...

                When your calender is working, you will have four separate calenders.  I know some users have inquired regarding an ALL VIEWS ON ONE calendar, but I don't think it exists.

                Can you confirm if any data is actually being entered in the database?

                 
                • Hey, there is stuff in the database. This is weird because I can see the gobbley-goop that I inserted as the subject and detailed description in the booking_event screen. Both user profiles are there as well.  But even though it is there in the database, it does not show on the calendars when viewing the user the website interface.

                   
                  • JVB
                    JVB
                    2009-03-25

                    So far this has me stumped.

                    ******** This section worked, because your database has data ************

                            $add_event_id = add_event($_SESSION['valid_user'], $scheduled_date_time_data, $_REQUEST['subject'], $_REQUEST['location'],
                                        $starting_date.' '.$_REQUEST['start_time'], $ending_date.' '.$_REQUEST['end_time'],
                                        $_REQUEST['recur_interval'], $_REQUEST['recur_freq'],
                                        $recur_date, $_REQUEST['desc']);

                    //*********  But this test fails  ************
                    //Maybe echo $add_event_id to confirm data exists

                    echo "Add event data: ".$add_event_id "<br />";

                    //*************************************

                            if (!empty($add_event_id)) {
                                // Redirect to display page for user options (edit/delete).
                                header('Location: ' . href_link(FILENAME_DETAILS_VIEW, 'event_id=' . $add_event_id . '&origin=' . FILENAME_ADD_EVENT . '&' . make_hidden_fields_workstring() . '&page_info_message=' . urlencode("Event added successfully!"), 'NONSSL'));
                                wrap_exit();
                            } else {
                                $page_error_message = "We could not add your event. Please check your information and try again.";
                            }

                     
                    • JVB
                      JVB
                      2009-03-25

                      add_event.php

                       
                      • I received this message.... What would you have me do?

                                            $recur_date, $_REQUEST['desc']);

                        //***** ADD THIS LINE **************
                        echo "Add Event ID: ".$add_event_id."<br />";
                        //**********************************

                                if (!empty($add_event_id)) {

                        Here is what was at the top of the page

                        Add Event ID:

                        The grotto website is at http://www.caves.org/grotto/timpgrotto/ but this feature is going to be hosted in back door fashion on my own personal site at http://nocavesinutah.com/booking_calendar/add_event.php

                        This personal site is not complete and all of the booking_calendar files are in their native folder in the root folder.

                        A test profile I set up is dog with the password kitten. I hope that with your eagle eye you can immediately see what is going on. Once I get it working on the host server I know, then I will tackle moving it to the grotto servers that are extremely restrictive.

                        Thanks again for your help!
                        Michael Leavitt

                         
                        • JVB
                          JVB
                          2009-03-26

                          The Calender looks perfect.

                          I was able to create a user account for me
                                (You'll want to delete that)

                          Therefore your connection to the database works.

                          I tried to create an entry, and I get the same error.

                          Please check the database and see if I actually entered test data for the 28th and let me know.

                          If the event exists for the 28th, then I don't know why $add_event_id is not being assigned a value.

                          I'll look at that next.

                           
                    • What would you have me do? Does the fact that I am on a GoDaddy shared Linux hosting server have anything to do with this? I read something about this script having pop-up windows, yet there is nothing popping. When you select a 4 hour range and every 15 minutes shows up to the right in the blue availability box, I don’t see how you make a final selection. Does that tell you that something else is not working?

                      Here are lines 137 to 180. They are stock with no modifications

                              // CHECK AVAILABILITY OF DATE TIME DATA
                             
                              $scheduled_slots = count($scheduled_date_time_data);
                              //echo "Scheduled Slots: ".$scheduled_slots."<br />";
                              $available_date_time_data = array ();
                              $unavailable_date_time_data = array ();
                              $availability_count = check_schedule_availability(
                                          $scheduled_date_time_data, $location_db_name[$_REQUEST['location']] );
                              //echo "Availability Count: ".$availability_count."<br />";
                              // All slots not available condition check.
                              if ($scheduled_slots > $availability_count) {
                                  $page_error_message = 'Availability Problem: Not all of the selected date and time slots ' .
                                          'are available for booking.  Please check the conflicting date and time slots, ' .
                                          'make the necessary changes to your booking form and try again.';
                                  $unavailable_date_time_data = find_schedule_unavailability(
                                          $scheduled_date_time_data, $location_db_name[$_REQUEST['location']] );
                                  if (count($unavailable_date_time_data) > 0) {
                                      $available_date_time_data = array_minus_array($scheduled_date_time_data, $unavailable_date_time_data);
                                  }
                              } else {
                                  $available_date_time_data = $scheduled_date_time_data;
                              }
                          }
                         
                          // IF ALL IS WELL WITH THE SCHEDULE DATA AVAILABILITY - ADD EVENT DATA
                         
                          //echo "valid user: ".$_SESSION['valid_user']."<br />user_id: ".get_user_id($_SESSION['valid_user'])."<br />";
                         
                          if ($page_error_message == '' && $_POST['add_event'] != "") {
                             
                              // Attempt to Add the Event to the Database
                              $add_event_id = add_event($_SESSION['valid_user'], $scheduled_date_time_data, $_REQUEST['subject'], $_REQUEST['location'],
                                          $starting_date.' '.$_REQUEST['start_time'], $ending_date.' '.$_REQUEST['end_time'],
                                          $_REQUEST['recur_interval'], $_REQUEST['recur_freq'],
                                          $recur_date, $_REQUEST['desc']);
                              if (!empty($add_event_id)) {
                                  // Redirect to display page for user options (edit/delete).
                                  header('Location: ' . href_link(FILENAME_DETAILS_VIEW, 'event_id=' . $add_event_id . '&origin=' . FILENAME_ADD_EVENT . '&' . make_hidden_fields_workstring() . '&page_info_message=' . urlencode("Event added successfully!"), 'NONSSL'));
                                  wrap_exit();
                              } else {
                                  $page_error_message = "We could not add your event. Please check your information and try again.";
                              }
                         
                          } // end of if ($page_error_message == '')

                       
    • VIP member
      VIP member
      2009-03-25

      It looks like the availability is ok and the schedule data has arrived but the add_event function returns False.

      Line 163 of add_event.php  is commented out:

        //echo "valid user:  ".$_SESSION['valid_user']."<br />user_id: ...

      If you remove the slashes what do you see? The line seems to be there for debugging purposes.

      The add_event function can be found from file includes/functions/booking_db_fns.php and there's some more debugging options.

       
      • At the very top of the returned page it says....

        valid user: dog
        user_id: 2

        That means that the user is valid, correct?
        I am learning how to troubleshoot and this one has me banging my head against the wall not knowing which file to be looking at to find the error. Have you got any thoughts as to where I should be concentrating?

        Michael Leavitt

         
    • VIP member
      VIP member
      2009-03-25

      Yes, the user is valid.

      You have to examine why the add_event function returns something that evaluates empty, as jvanbonn wrote. In practise, the function returns false, I think.

      The add_event function can be found from file
      includes/functions/booking_db_fns.php 

      The function begins at line 584. There's several conditions where it returns false, for example beginning from line 613:

        if (empty($user_id)) {
           return false;
        }

      If you find out all of these and for example add something like this line you might get further:

        if (empty($user_id)) {
           echo "Returning false from checkpoint A ";
           return false;
        }

       
      • I have been moving through the script from line 584 and got nothing until line 630 where I got:

        Returning false from checkpoint A

        This comes after this portion of the script...

          // insert the new event
          $result = wrap_db_query("INSERT INTO " . BOOKING_EVENT_TABLE . " SET
                                user_id = " . mysql_real_escape_string($user_id) . ",
                                subject = '" . mysql_real_escape_string($subject) . "',
                                location = '" . mysql_real_escape_string($location) . "',
                                starting_date_time = '" . mysql_real_escape_string($starting_date_time) . "',
                                ending_date_time = '" . mysql_real_escape_string($ending_date_time) . "',
                                recur_interval = '" . mysql_real_escape_string($recur_interval) . "',
                                recur_freq = " . mysql_real_escape_string($recur_freq) . ",
                                recur_until_date = '" . mysql_real_escape_string($recur_until_date) . "',
                                description = '" . mysql_real_escape_string($description) . "',
                                date_time_added = NOW(),
                                last_mod_by_id = '',
                                last_mod_date_time = '0000-00-00 00:00:00'");
          if (!$result) {
              echo "Returning false from checkpoint A ";
                return false;

        That is a long queary and I have no idea how to troubleshoot. Do you see anything amiss?

        None of the other return false locations  either before or after the one mentioned above resulted in any returns.

        Michael Leavitt

         
        • VIP member
          VIP member
          2009-03-26

          You could try to find out what the form has passed to the script. Maybe just anywhere put this line:

          echo '<pre>' . print_r($_POST) . '</pre>';

          You can troubleshoot that query, too. Now it says

          // insert the new event
          $result = wrap_db_query("INSERT   .... etc

          You could modify it like this:

          // put the query in a new variable:
          $testquery = "INSERT .... etc

          // print the query contents:
          echo $testquery;

          // continue to query:
          $result = wrap_db_query($testquery);

           
    • Why do some of the statements have a double quote followed by a single and other lines only have a double quote?

      Take a look at the user_id and recur_freq lines to see what I mean.

        // insert the new event
        $result = wrap_db_query("INSERT INTO " . BOOKING_EVENT_TABLE . " SET
                              user_id = " . mysql_real_escape_string($user_id) . ",
                              subject = '" . mysql_real_escape_string($subject) . "',
                              location = '" . mysql_real_escape_string($location) . "',
                              starting_date_time = '" . mysql_real_escape_string($starting_date_time) . "',
                              ending_date_time = '" . mysql_real_escape_string($ending_date_time) . "',
                              recur_interval = '" . mysql_real_escape_string($recur_interval) . "',
                              recur_freq = " . mysql_real_escape_string($recur_freq) . ",
                              recur_until_date = '" . mysql_real_escape_string($recur_until_date) . "',
                              description = '" . mysql_real_escape_string($description) . "',
                              date_time_added = NOW(),
                              last_mod_by_id = '',
                              last_mod_date_time = '0000-00-00 00:00:00'");
        if (!$result) {
              return false;
        }

       
    • Danny Larsen
      Danny Larsen
      2009-04-03

      I'm having the same problem. When I print the sql query and copy it into phpmyadmin it runs fine. I sure hope that someone will solve this.

       
      • Last week I sent privately complete access to jvanbonn with a special limited ftp access to the site and the access information to my database and I have heard back absolutely nothing. I would still love to move forward with this script, but I was backed into a corner and paid $49 for a temporary solution with a far less powerful JustBookIt script.

        It gets frustrating as you try to learn how to implement and tweak scripts when you don’t possess a full understanding of how to best troubleshoot the advanced scripting issues. I thought we were making progress, but I am not holding my breath any longer. Hopefully jvanbonn will eventually come up with something.

        Michael Leavitt

         
      • VIP member
        VIP member
        2009-04-03

        So the insert query in the function includes/functions/booking_db_fns.php returns false, but the same query works well with phpmyadmin.

        What does your query look like?

        What data the query puts in the database?

         
    • Danny Larsen
      Danny Larsen
      2009-04-04

      The query is:
      INSERT INTO booking_event SET user_id = 1, subject = 'test subject', location = 'loc1', starting_date_time = '2009-04-04 07:00', ending_date_time = '2009-04-04 07:30', recur_interval = 'none', recur_freq = 1, recur_until_date = '2009-04-04', description = 'Test description', date_time_added = NOW(), last_mod_by_id = '', last_mod_date_time = '0000-00-00 00:00:00'

      I have tried locating the error and it comes from here, when it tries to run the statement with wrap_db_query:
      .......
                              last_mod_date_time = '0000-00-00 00:00:00'");
       
        if (!$result) {
                print("ERROR");
              return false;
        }
        // Get the event_id (auto) for the event just added to the event table.
        $event_id = wrap_db_insert_id();
      .......

      When this is run from the add_event, it prints ERROR at the top, so $result is false.

       
      • VIP member
        VIP member
        2009-04-04

        How about mysql_error()?

        if (!$result) {
        print("ERROR ");
        echo mysql_error();
        return false;
        }