Page 1 of 1

Mysql errors: sql modes-strict mode, TIMESTAMP implicit DEFAULT is deprecated

Posted: 27 Oct 2016, 09:03
by Alecos

Code: Select all

2016-10-27T08:05:25, 0, Warning, TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-10-27T08:05:25, 0, Warning, 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
class.rating.php
pastebin.com/smgUqUuk

create_tables.php
pastebin.com/C2KEGNVT

Since the code is very big I posted the source code to pastebin...
How to fix the warnings showed in the log? I'm using MySQL 5.7 and PHP 7.0.12 and Apache 2.4

Mysql errors: sql modes-strict mode, TIMESTAMP with implicit DEFAULT is deprecated

Posted: 27 Oct 2016, 11:01
by Admin
Hello
1. I think those mysql errors are not from the Ajax Rating script, the script has not a column with TIMESTAMP value.
Perhaps it is something from the mysql configuration in my.cnf or my.ini.
I not know about mysql configs.

Mysql errors: sql modes-strict mode, TIMESTAMP with implicit DEFAULT is deprecated

Posted: 27 Oct 2016, 16:12
by Alecos
Solved!!! The fault was of MySQL and not of your script... solved the issue by editing the following files:

find this in my.ini:

Code: Select all

# Set the SQL mode to strict
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
replace with this in my.ini

Code: Select all

# Set the SQL mode to strict
sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
find this in my-default.ini

Code: Select all

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLE
replace with this in my-default.ini

Code: Select all

sql_mode=NO_ENGINE_SUBSTITUTION
restart apache & mysql server, see into logs and the warning will disappear... Just tested!!!

Mysql errors: sql modes-strict mode, TIMESTAMP with implicit DEFAULT is deprecated

Posted: 27 Oct 2016, 16:17
by Alecos
For solving this:

Code: Select all

Warning, TIMESTAMP with implicit DEFAULT value is deprecated...
add to my.ini this directive:

Code: Select all

explicit_defaults_for_timestamp=1

Mysql errors: sql modes-strict mode, TIMESTAMP implicit DEFAULT is deprecated

Posted: 27 Oct 2016, 16:44
by Admin
Thank you for posting the solution to fix those errors. Maybe will be useful for someone.