I have a date input stored in a variable (no hour etc, just the date). I am trying to format it to then compare it to a date in MySQL database, but keep getting the Following error in reference to my PHP file…
"Notice: A non well formed numeric value encountered"
You'll see in my code below I've tried a couple of different methods of converting my date into a MySQL readable date, but to no avail.
I've been trying to do this conversion in the PHP file itself, is that right?
I haven't shown the connection code below as I know that works and may confuse things.
if (isset($_POST["date"])) {
$date = $_POST["date"];
$sqlDate = date("Y-m-d", $date);
// $sqlDate = strftime('%Y-%m-%d',$date);
$url = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? "https" : "http") . "://$_SERVER[HTTP_HOST] $_SERVER[REQUEST_URI]";
$id = basename($url);
// echo $id;
$stmt = $conn->prepare("SELECT * FROM planning WHERE intervenant = :id AND date = :sqlDate");
$result = $stmt->execute([':id' => $id, ':sqlDate' => $sqlDate]);
if ($stmt->rowCount() > 0) {
$output = array();
$output = $stmt->fetch(PDO::FETCH_ASSOC);
echo json_encode($output);
} else {
$errors = "No data found for this date";
echo json_encode($errors);
}
// $conn->close();
}
The aim is pretty self-explanatory, I'd like to be able to confirm my input date with a list of dates within a database, then pull matching rows out of the database to be shown/used client side…
Thank you for any help.