OpenCart 實裝錯誤 php73 mysql8

出現php 500

tail -30 /var/log/httpd/error_log
[Sun May 30 18:32:48.970395 2021] [php7:error] [pid 6609] [client 111.242.65.36:12392] PHP Fatal error:  Uncaught Exception: Error: Variable 'sql_mode' can't be set to the value of 'MYSQL40' xxxxxxxxxxxxxxx ....

解決方法

  • install/cli_install.php

    Search for $db->query("SET @@session.sql_mode = 'MYSQL40'"); and replace with $db->query("SET @@session.sql_mode = ''");

  • install/model/install/install.php

    Search for $db->query("SET @@session.sql_mode = 'MYSQL40'"); and replace with $db->query("SET @@session.sql_mode = ''");

  •  

 

Uncaught Exception: Error: Incorrect DATE value: '0000-00-00

go to system/library/db/mysqli.php

find

  • $this->connection->query("SET SESSION sql_mode = 'NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_ENGINE_SUBSTITUTION'");
  • replace
  • $this->connection->query("SET SESSION sql_mode = 'NO_ZERO_IN_DATE,NO_ENGINE_SUBSTITUTION'");
  •  

 

總之找 error_log 比較容易找出問題

← 回列表