formtools / core

The Form Tools Core.
https://formtools.org
205 stars 78 forks source link

SQL issue, SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '207-0' for key 'PRIMARY' #887

Open ItProbablyIsAl opened 1 year ago

ItProbablyIsAl commented 1 year ago

Installed Form Tools uneventfully and am attempting to add a form. PHP version is 5.3.29, MySQL is 5.1.73. The SQL error appears no matter if I try to create a form from scratch or attempt to import a form using process.php. I feel like I checked the dumb stuff, but I may not be smart enough to know what's actually dumb. Any assistance or guidance would be very welcome. I've gone through and made everything writable (775 on the files and directories) just in case with no effect. I've truncated all the empty tables to reset the autoID info and still no luck. Thank you for any assistance that you can provide.

jweese74 commented 1 year ago
  1. You are using outdated PHP and MySQL versions, which may cause compatibility issues. Upgrade PHP to version 7.4 or higher and MySQL to version 5.7 or higher to ensure compatibility with FormTools.
  2. Verify that your FormTools installation is properly connected to your MySQL database. Check the global/config.php file to ensure the database credentials (hostname, username, password, and database name) are correct.
  3. The SQL error indicates a duplicate entry in the primary key column. Reset the auto-increment value by running an SQL query like this:

ALTER TABLE your_table_name AUTO_INCREMENT = your_desired_starting_value;

Replace your_table_name with the name of the table causing the issue, and your_desired_starting_value with a number higher than the current maximum value in the primary key column.

  1. Examine your PHP code and FormTools settings to find out why the duplicate entry is being created. Review any import scripts, form submissions, or database update operations in your code.
  2. In rare cases, database corruption might cause this issue. Create a backup of your data and then attempt to repair the database using the REPAIR TABLE command:

REPAIR TABLE your_table_name;

Replace your_table_name with the name of the table causing the issue.

  1. Ensure that your database schema is set up correctly and matches the expected schema for FormTools.
  2. Ensure file and directory permissions are set to 775 and that the owner and group are correctly set, allowing your web server to read, write, and execute.
  3. Enable error reporting in your PHP configuration to get more detailed information about any issues. You can do this by modifying your php.ini file or adding the following lines at the beginning of your PHP script:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

If things start working again, don't forget to back out the modifications or add//to comment out the lines.

Good luck.