0

I'm working on a legacy app that runs PHP 5.3 and MySQL 5.1. Currently I'm trying to update to MySQL 5.7, but I found a strange behavior and I'm not sure what causes it (I'm pretty sure it's mysqli).

On a new DB (MySQL 5.7) when you try to execute a query like so:

$connection->query('INSERT INTO `utf_items` () VALUES ()');

I'm not surprised that I get an error saying that some fields do not have default values.

BUT, on MySQL 5.1 running the same query through mysqli, I get no such error and fields that cannot be NULL and are of type varchar are saved as empty strings ''.

query() is mysqli::query().

Running this query INSERT INTO `utf_items` () VALUES () straight to MySQL (doesn't matter what version) i get the desired error.

Am I missing some kind of option somewhere? I couldn't find similar behavior in other questions.

Dharman
  • 26,923
  • 21
  • 73
  • 125
  • 2
    This has noting to do with PHP or mysqli. You have a different SQL_MODE set up on the new server. Compare them. – Dharman Aug 31 '21 at 10:29

0 Answers0