为什么PC和笔记本电脑的代码结果不同

Why is the result of code is different between PC and Laptop

这里有我之前威胁的声明 PHP MySQL How to select 2 specific and 1 common value over 2 tables? 有些事情让我感到困惑,但首先是重要代码部分:

$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
}?>

这个函数只是寻找一些相似的和现有的值。 它通过 Xampp PHP 版本 7.3.7 在我的电脑上工作/ Xampp 上的笔记本电脑版本是 7.1.11

在我的电脑上,服务器字符集是 cp1252 西欧 (latin1) 在我的笔记本电脑上,它也是 cp1252 West European (latin1) 。 utf8mb4 具有相同的结果。 好的,现在是最后一个序列: AND table2.versendet = '0000-00-00 00:00:00' 看,如果那里有。

在我的电脑上,这对我的代码来说已经足够了,如果 保存的值为 '0000-00-00 00:00:00' -> 代码用当前日期时间更新它。

如果我在我的笔记本电脑上启动此代码,代码说,不,'0000-00-00 00:00:00' 没有任何内容,并给我一条错误消息。 但是如果我将该代码更改为 AND table2.versendet = date('Y-m-d' H:i:s' = '0000-00-00 00:00:00') 它像在我的电脑上一样工作,我完全不知道为什么。

所以,如果有人理解我,请告诉:谁是我的错误。提前致谢:)

这是一个有效查询的示例。虽然它可能无法解决您所有的问题,但它至少是一个更好的起点...

SELECT DISTINCT t1.unique_code -- pointless to select both columns when we know (because we have specified) that both hold the same value
              , t1.spediteur   -- obviously we know that this will be 'Dachser'
              , t2.versendet   -- and this will be '0000-00-00 00:00:00'
                               -- (assuming correspondong rows exist)
           FROM table1 t1
           JOIN table2 t2
             ON t2.unique_code = t1.unique_code
          WHERE t1.unique_code = ?
            AND t1.spediteur = 'Dachser'
            AND t2.versendet = '0000-00-00 00:00:00'