I'm having troubles trying to insert a timestamp into MySQL always shows 0000-00-00 00:00:00
The scheme for the table is this:
CREATE TABLE `Rawdata` (
`Exchanger` varchar(30) NOT NULL,
`Timestamp` datetime NOT NULL,
`Last` float NOT NULL,
`Bid` float NOT NULL,
`Ask` float NOT NULL,
PRIMARY KEY (`Exchanger`,`Timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
And the code of the php :
$query = "INSERT INTO Rawdata (Exchanger,Timestamp,Last,Bid,Ask) VALUES(?,?,?,?,?)";
$result = $link->prepare($query);
$result->bindParam(1,$exchanger,PDO::PARAM_STR);
$result->bindParam(2,$timestamp,PDO::PARAM_STR);
$result->bindParam(3,$last,PDO::PARAM_STR);
$result->bindParam(4,$bid,PDO::PARAM_STR);
$result->bindParam(5,$ask,PDO::PARAM_STR);
$result->execute();
Also this is the var_dump() of the variables
array(5) { [1]=> string(6) "Mt.Gox" [2]=> string(10) "1391036493"
[3]=> string(6) "929.00" [4]=> string(6) "929.00" [5]=> string(6) "932.90" }
I don't know why is not working.. Because in other function i update other table with the same timestamp column and it works :/
What can be wrong?
Thanks in advance
Edit:
The $timestamp
variable comes from this:
$apivariable = string(16) "1391038069839089"
then i use the following:
$timestamp = time($apivariable)
Pastebin: