Duplicate tblinvoices Errors

Problem

While performing an action that creates an invoice (including the daily automation cron tasks or when your staff or a client places an order), you see the following Oops! error message:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2147483647' for key 'tblinvoices.PRIMARY' in /path/to/whmcs/vendor/illuminate/database/Connection.php:464

Cause

The Invoice Starting # setting is an integer value that is larger than 2,147,483,648 (2 billion 100 thousand), which is higher than MySQL® can accommodate.

Solution

  1. Using a tool like phpMyAdmin, run the following query against WHMCS’s MySQL database and note the result:

    SELECT MAX(invoiceid) + 1 FROM tblinvoiceitems;

  2. Log in to the WHMCS Admin Area.

  3. Go to the Invoices tab at Configuration () > System Settings > General Settings.

  4. Enter the value that you noted in step 1 for Invoice Starting #.

  5. Click Save Changes.

Invoice Starting # will be empty after saving. This is normal.

Last modified: November 19, 2024