Hi,
i need to add my event’s published time to mysql. I can not find convert photon date format to php/mysq date format. Here is the codes:
if ($_SERVER[“REQUEST_METHOD”] == “POST”) {
$sql = "INSERT INTO Rfid (PhotonId, BRfid, RfidDate) VALUES ('ok', 'ok', ?)";
if($stmt = mysqli_prepare($GLOBALS['link'], $sql)) {
mysqli_stmt_bind_param($stmt, "?(type?)", $_POST["published_at"]);
mysqli_stmt_execute($stmt);
}
}
Your code has a blank (actually a “?”) for the date value. How are you actually obtaining the date? Are you getting the date from a cloud variable or perhaps a publish/subscribe? Where is the code that publishes the date from the Photon? Showing all those missing pieces will help us help you.
Particle publish an event and data. And i post it via WebHook.
Also my code line which has '?'
mysqli_stmt_bind_param($stmt, “s”, $_POST[“published_at”]);
In mysql table, the date column format is string. And it works. But it is string that you see at code. I need date format. I solve problem by using php date function. I did it thank you
1 Like