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
// also set variable for enter timezone like this
SET time_zone=’+00:00′;
//or do this one
CREATE TABLE test_timestamp (
t1 TIMESTAMP
);
You wrong type into
bindParam
, instead ofPDO::PARAM_INT
you needPDO::PARAM_STR
Reference: