ich have here an statement from my threat before PHP MySQL How to select 2 specific and 1 common value over 2 tables? and something confuses me, but first the section of important code:
$stmt = $pdo->prepare("SELECT
table1.spediteur,
table2.versendet,
table2.unique_code,
table1.unique_code
FROM table1
INNER JOIN table2
ON table1.unique_code = table2.unique_code
WHERE table1.unique_code = $scanned_number
AND table2.unique_code = $scanned_number
GROUP BY table1.spediteur,
table2.versendet,
table2.unique_code,
table1.unique_code
HAVING table1.spediteur = 'Dachser'
AND table2.versendet = '0000-00-00 00:00:00'
");
$stmt->execute([$scanned_number]);
$result = $stmt->fetch();
if ($result) {
?> the scanned number matches the given parameter
<?php
$sql = "UPDATE table2 SET versendet = date('Y-m-d H:i:s') WHERE unique_code = $scanned_number";
$stmt = $pdo->prepare($sql);
$stmt->execute();
} else {
?> the scanned number don´t matches
<?php
}?>
This function just look for some similar and existing values. It works on my PC via Xampp PHP Version 7.3.7 / Laptopversion on Xampp is 7.1.11
On my PC the server character set is cp1252 West European (latin1)
On my Laptop it is cp1252 West European (latin1) , too. utf8mb4 has the same results.
Okay , now the last sequence:
AND table2.versendet = '0000-00-00 00:00:00'
see, if there's that there.
On my PC this is enough for my Code and if the saved value is '0000-00-00 00:00:00' -> the code update it with current datetime.
If i start this code on my Laptop, the Code saye, no there is nothing with '0000-00-00 00:00:00' and gives me an error message.
But if i change that code to
AND table2.versendet = date('Y-m-d' H:i:s' = '0000-00-00 00:00:00')
it works like on my PC and i absolutly don´t know why.
So, if anyone understand me, please tell: who is my mistake. Thanks in advance :)