0

First of all, sorry for my language.

Actually, I've tried to move a PHP application using MySQL 4 to another server using MySQL 5.6.11.

Like a lot of people, I had the problem: "Incorrect integer value: '' for column 'id' at row 1" I understood where the problem was but choices I have don't satisfied me.

Choices are :

  1. go back to MySQL 4 - not possible
  2. modified my.ini and sql-mode. But Mysql impact a lot of bases and I don't think it's a good idea to reduce the security.
  3. put security in the php code, but it will take a lot of time.

Do you think there are other solution I didn't find?

Mureinik
  • 297,002
  • 52
  • 306
  • 350

1 Answers1

0

This happens when an INSERT happens with an empty string for id like this:

INSERT INTO TABLE SET id = ''

To fix that, assuming id is the Primary Key, search inside your project files for INSERT INTO to find all insert queries and remove id completely from list of the columns. Then in MySQL make the id column auto increment.

Now when a record is being inserted, id would automatically get a unique integer value.

UPDATE:

If id is not Primary Key, again search inside your project files for INSERT INTO and make id value NULL:

INSERT INTO TABLE SET id = NULL
Sam
  • 93
  • 1
  • 9