-2

So I have a list of servers as a website - out of no where - when you try to add a new server it gives an error -

Array ( [success] => [error-codes] => Array ( [0] => missing-input-secret ) ) Unhandled Exception. SQLSTATE[HY000]: General error: 1364 Field 'ServerVotes' doesn't have a default value You can find the error back in the log.

I went ahead and set a default value for it in phpymadmin, it asked for default values of more things - and after I set it it gave me some problems with the database. Any ideas what could be the source of this issue and where I could try to fix it?

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • All I've done is try to set the phpmyadmin default value, but it just says some other stuff dont have default values, and then some problems with the database. I just want help where I could possibly find the error log or how to fix something like this. – Robert Pringe May 24 '19 at 10:48
  • We need to know "other stuff" and "more things". Are these date columns by any chance? – Martin May 24 '19 at 10:51
  • Well, what are the problems with the database? What did you do to cause this? Did you try to install a new version of your php software? – Adder May 24 '19 at 10:52
  • the more things are literally the same. instead of servervotes, it says serverrank, and some SAME stuff with the SAME error. And what do you mean by date columns? – Robert Pringe May 24 '19 at 10:52
  • And I did nothing. One day it just popped. – Robert Pringe May 24 '19 at 10:53
  • 1
    Do you use MySQL? – Martin May 24 '19 at 11:03

1 Answers1

2

The source of your problem is your MySQL version has been updated to 5.7 (or above) or otherwise is now using "SQL Strict" mode, so as the name implies, you are needing to update the way your data is set, so it fits the strict criteria.

1)
A (unwise) work around is to change your MYSQL settings on the server to TURN OFF STRICT MODE (temporarily) and then correct your data to fit the new strict mode, before turning it back on.

Typically, Strict Mode (good reading material) includes:

  • Empty values should be null
  • Invalid dates MUST be null
  • All values should have a default setting (this is your error).
  • Data longer than the column row length will now result in a failed insert rather than a cut off (Example: inserted data is 20 chrs and the column length is VARCHAR(15)). Therefore column lengths must be checked before insert/update.
  • GROUP BY has got a lot more fiddly.

2)
You can also look up This specific MySQL Error Code and that will guide you to resolve this issue.

3)
Further, you need to properly handle the exception that this causes, in your PHP database interface class / code.

4)
You may get more information from your MySQL Error log and possibly your PHP Error Log.

Martin
  • 22,212
  • 11
  • 70
  • 132
  • Unfortunately after talking to the host, I'm unable to remove the strict mode of SQL. I went ahead and sell the default value of all the empty ones and the next error I've encountered - Array ( [success] => [error-codes] => Array ( [0] => missing-input-secret ) ) Unhandled Exception. SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column `database`.`servers`.`VotifierPort` at row 1 You can find the error back in the log. – Robert Pringe May 24 '19 at 19:18
  • @RobertPringe You want to keep strict mode, it's better, but you need to conform to it. – Martin May 25 '19 at 09:27