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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:09:08+00:00 2026-05-23T09:09:08+00:00

This has been an ongoing struggle for me for the last four days. I

  • 0

This has been an ongoing struggle for me for the last four days. I was really hoping to work this out enough to not have to ask here, because it’s a lot of code, but I’m afraid I have tried and tried to reduce the problem down, and it’s just like I’m chasing my tail. I have eliminated as much code as I think I can-I may have eliminated more than I should have to easily see what is going on, so feel free to ask for clarification.

The synopses:

I am pulling a calendar feed from Google calendar and populating my own calendar. My calendar has added functionality where I have a database of “timeline events” that are like to-do items that happen a certain number of days (DaysFromEvent) from the regular event.

The feed gets pulled in by this cron and searches for any new events on the google calendar and adds them to the database. (This part seems to be working as it should). The cron also looks at the ModifiedInGoogle field to see if the event has been modified and if so it updates the event in the database. That also seems to be working. The crux is that if the main event is modified, then I also need to look in the database and pull any timeline event that is associated with the main event and change its start time based on StartTime + DaysFromEvent

I think I pretty much have this script doing that, but I seem to be having trouble with my while loop that is inside of the if statement.

When I run a modified event through the script, I only get echoed up to the point of: echo "Event ID: ".$tempEventID. ", Promotional Time Line: ".$tempTimelineID.", Parent Event ID: ".$tempParentEventID."<br>";

I should be getting am echo from the while loop, but I’m not. My apologies for the long words, and even more apologies for the long code to follow. I’m a newbie at this, so please be gentle. 🙂

I’m about ready to give up and hire someone to finish this for me because I’m a musician not a programmer!

if((int)$feed->totalResults>0)  { //checking if at least one event is there in this date range

    foreach ($feed as $event) { //iterating through all events and pulling all the info to assign the variables below.

        $UserID= "42";
        $eventDatabase = "events";  

        //Setting startDate and startTime and endDate and endTime
        $StartDate = $event->when[0]->startTime;
        $date = strtotime($StartDate);
        $StartDate = date('Y-m-d H:i:s',$date);
        $StartArray = explode(' ', $StartDate);
        $StartTime = $StartArray[1];
        $EndDate = $event->when[0]->endTime;
        $date = strtotime($EndDate);
        $EndDate = date('Y-m-d H:i:s',$date);
        $EndArray = explode(' ', $EndDate);
        $EndTime = $EndArray[1];  

        $ModifiedInGoogle = $event->updated->text;
        $GoogleID = $event->id;

        $EventName = stripslashes($event->title);
        $PromotionalTimeLine = "0";
        $ParentEventID = "NULL";
        $DaysFromEvent = "";


        //We are seeing if the Event is already in the database by looking for the googleID
        $query = "SELECT * FROM ".$eventDatabase. " WHERE GoogleID='$GoogleID'";
        $result = mysql_query($query);

        $row = mysql_fetch_array($result, MYSQL_ASSOC);

        //This loop UPDATES events if ModifiedInGoogle string is different than what is already in the database
        if($ModifiedInGoogle != $row['ModifiedInGoogle']){

            //Variables for modifying the timeline start time
            $ModifiedEventStartTime = $row['StartTime'];
            $tempParentEventID = $tempEventID = $row['EventID'];
            $tempTimelineID = $row['PromotionalTimeLine'];

            //THIS ECHOS AS I EXPECT IT SHOULD
            echo "Event ID: ".$tempEventID. ", Promotional Time Line: ".$tempTimelineID.", Parent Event ID: ".$tempParentEventID."<br>";

            //Updates main event when modified in google:
             mysql_query("UPDATE ".$eventDatabase." SET 
             EventName = '$EventName', 
             StartDate = '$StartDate', 
             StartTime = '$StartTime', 
             EndTime = '$EndTime', 
             EndDate = '$EndDate', 
             Description = '$Description', 
             AllDay = '$AllDay', 
             CreatedOn = '$CreatedOn', 
             GoogleID = '$GoogleID', 
             ModifiedInGoogle = '$ModifiedInGoogle'

             WHERE GoogleID='$GoogleID' ");

            //Query to select the timeline events that have the same ParentEvenID-this is where everything seems to start falling apart...
            $query = "SELECT * FROM events WHERE ParentEventID='.$tempParentEventID.' AND GoogleID IS NULL";
            $tempresult = mysql_query($query);

        while($row = mysql_fetch_array($tempresult, MYSQL_ASSOC)){

            $tempEventID = $row['EventID'];
            $tempDaysFromEvent = $row['DaysFromEvent'];
            $tempStartDate = $row['StartDate'];

            //THIS LINE IS NOT ECHOING
            echo "EventID: ".$tempEventID.", Start Date: ".$tempStartDate.", Days From Event: ".$tempDaysFromEvent.", Parent Event ID: ".$row['ParentEventID']."<br>";

            //IF STARTDATE IS DIFFERENT FROM HOW IT USED TO BE, UPDATE IT.
            list($year, $month, $day) = explode("-", $tempStartDate);
            $tempStartDate      =   $tempEndDate    =    date("Y-m-d", mktime (0,0,0,$month,$day+$tempDaysFromEvent,$year));
            echo "TempStart Date:".$tempStartDate."<br>";

            //Query to update the startdate of the events
            mysql_query("UPDATE".$eventDatabase." SET
            StartDate = '$tempStartDate'
            WHERE EventID = $tempEventID
            ");
        }  //Closes While loop


        }  //This closes the update if modified if statement

    //This loop adds NEW EVENTS
    if (!mysql_num_rows($result)) {

    //Insert NEW EVENTS

    }
} //ends main event loop
} else  { 

  echo "No event found";
}
  • 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-23T09:09:09+00:00Added an answer on May 23, 2026 at 9:09 am

    Within the line

    $query = "SELECT * FROM events WHERE ParentEventID='.$tempParentEventID.' AND GoogleID IS NULL";
    

    You have included single quotes instead of doubles. Did you mean to have

    $query = "SELECT * FROM events WHERE ParentEventID=".$tempParentEventID." AND GoogleID IS NULL";
    

    or maybe without the dots (if you want to keep the delimiters)

    $query = "SELECT * FROM events WHERE ParentEventID='$tempParentEventID' AND GoogleID IS NULL";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This has been stumping me for a few days now. I have a stored
This has been answered by other people but I can't figure out how to
This has been a problem that I haven't been able to figure out for
This has been driving me crazy for a few days. Why doesn't the following
This has been a rather problematic issue on numerous occasions. We have alot of
This has been driving me crazy for the past few minutes I have a
This has been driving me crazy for the past couple of hours. I have
This has been bugging me lately. Say I have a base class Base. If
This has been driving me mad for a few days... Create a new Window-based
This has been a head-banger for me. I have looked at all of the

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.