Search code examples
phpmysqltimeschedule

mysqli schedule time error: not added into the table


default command time schedule

CREATE EVENT event_name
ON SCHEDULE
EVERY {x}
{SECOND | MINUTE | HOUR | DAY | MONTH | YEAR | WEEK}
DO
{SQL COMMAND};

my own event

$auto = "CREATE EVENT event_name
ON SCHEDULE
EVERY 50 second
DO
INSERT into mytable (id, account, date)
          VALUES('$id', '$account','$date'  )";             


  if(mysqli_query($conn, $auto)){ 
                                                 echo '<script>alert("Data success to save !")</script>';
                                                }
                                                else{
                                                echo '<script>alert("Data failed to save !")</script>';
                                                }           
;

the code should be work fine but the query is not added into mysql table

what i miss?


Solution

  • You should run SET GLOBAL event_scheduler = ON; in mysql to start Scheduled Event. To stop it please exicute SET GLOBAL event_scheduler = OFF;