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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:37:10+00:00 2026-06-16T15:37:10+00:00

I am making a recurring event system and have to hard code a check

  • 0

I am making a recurring event system and have to hard code a check to see if an event has passed to make a new one. (No, I can not make a cron job because the system base is Windows and no, I do not have access to the task scheduler.)

This is the code I have so far:

<?php
require('common.php');
$query = "SELECT 
             *
          FROM 
             DD_events
      ";
try{
$stmt = $db->prepare($query);
$result = $stmt->execute();
}
catch(PDOException $ex){
die("Failed to run query: " . $ex->getMessage());
}
$chk = $stmt->fetchall();
//print_r($chk);

foreach ($chk as $chks) {
if (time() > $chks['event_date']) {
//Add 1 day to event time
$time = strtotime($chks['event_date']);
$newTime = $time + 86400; // 24 * 60 * 60

// Create query to make the next event
    $query = "INSERT INTO
            DD_events (event_name, event_date, initiator, min_lvl, max_level)
              VALUES 
            ({$chks['event_name']}, {$newTime}, 0, {$chks['min_lvl']}, {$chks['max_level']})
      ";
    try
    {
        // These two statements run the query against your database table.
        $stmt = $db->prepare($query);
        $stmt->execute();
    }
    catch(PDOException $ex)
    {
        // Note: On a production website, you should not output $ex->getMessage().
        // It may provide an attacker with helpful information about your code. 
        die("Failed to run query: " . $ex->getMessage());
    }
}
}

it returns this error:

Failed to run query: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 200)' at line 4

Can anyone spot the error I am making because I have been looking at it for the past 30 mins and can’t see it.

  • 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-16T15:37:11+00:00Added an answer on June 16, 2026 at 3:37 pm

    Perhaps an easier way to do the same thing:

    INSERT INTO DD_events
    (event_name, event_date, initiator, min_lvl, max_level)
    SELECT event_name, DATE_ADD(event_date, INTERVAL 1 DAY), 0, min_lvl, max_lvl
    FROM DD_events
    

    This will create a new event for each existing event one day later (which is what you said the code was supposed to do) and eliminates the need for basically your whole script

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

Sidebar

Related Questions

Making a new site but something is happening to it in IE8. The social
Making a word document of our network set-up. We have about 7 servers and
Making a new site but something is happening to it in IE. I've purchased
I have a Backbone model that is making a successful server request. The callback
I am in the process of making a PHP web application. I have a
I have an event that is currently defined with no event arguments. That is,
I have a current system using IIS 6 and 7, written in ASP.NET with
I have a function where I'm making a call to a MVC controller that
I'm making an iPhone app that uses Core Plot at one point in the
i have been trying the code using mutex but im unable to open my

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.