$startDate = time(); $endDate = mktime(date("h"), date("i"), date("s"), date("m") , date("d")+1, date("Y")); $stmt = $this->conn->prepare("INSERT INTO timer(id, startDate, range, endDate) values(?, ?, ?, ?)"); $stmt->bind_param("siii", $id, $startDate, $range, $endDate); $result = $stmt->execute(); $stmt->close(); 

Mistake:

 check the manual that corresponds to your MySQL server version for the right syntax to use near 'range, endDate) values(?, ?, ?, ?)' at line 1 
  • one
    And what kind of error is that? - Dmitriy Simushev
  • 1) $ id did not show create table timer , $ range can be empty for you, but they are mandatory in the database 2) show show create table timer so that they know what should be written there 3) show the error itself - BOPOH
  • one
    read this , most likely it will be enough to `range` range in quotes (i.e. `range` ) - BOPOH
  • A similar problem in SQLite + Ruby on Rails : the solution is generally the same, wrap the identifier in the corresponding quotes. - D-side

1 answer 1

Before connecting to mysqli, you should always write a line

 mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); 

after that, the DB will start reporting itself what kind of error has occurred. It remains only to read and correct.