skip to Main Content

I’ve recently upgraded MySQL to version 5.7.35 and PHP to version 7.4.21.

This PHP script is failing to enter the data into ‘my_table

$hoje = date("Y-m-d H:i:s"); 

$stmt = $db->prepare("INSERT INTO my_table(teste_id,data) VALUES (:ftesteid, :fdata)");

$stmt->bindParam(':ftesteid', $testeMaisRecente, PDO::PARAM_INT);

$stmt->bindParam(':fdata', $hoje, PDO::PARAM_INT);

$stmt->execute();   

Although the variable $hoje is correct, it just enters 0000-00-00 00:00:00 into column data

2

Answers


  1. // also set variable for enter timezone like this

    SET time_zone=’+00:00′;

    //or do this one

    CREATE TABLE test_timestamp (
    t1 TIMESTAMP
    );

    Login or Signup to reply.
  2. You wrong type into bindParam, instead of PDO::PARAM_INT you need PDO::PARAM_STR
    Reference:

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search