Log error: campaign_lead_event_failed_log - Need help please

Your software
My Mautic version is: v4.4.9
My PHP version is: 7.4.33
My Database type and version is: 8.0.34

Your problem
My problem is:

These errors are showing in the log: [2023-09-12 18:51:01] mautic.ERROR: CAMPAIGN: An exception occurred while executing ‘REPLACE INTO mautic_campaign_lead_event_failed_log( log_id, date_added, reason) SELECT id, :dateAdded as date_added, :message as reason from mautic_campaign_lead_event_log WHERE is_scheduled = 1 AND lead_id = :contactId AND campaign_id = :campaignId AND rotation = :rotation’: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':dateAdded as date_added, :message as reason from mautic_campaign_lead_event_log ’ at line 2 {“hostname”:“{server_url}”,“pid”:1633831}

Steps I have tried to fix the problem: Nothing at the moment, browsed different topics but didn’t find how to make it, but seems to be a common problem.

It’s been like this for 5 years, so it’d be weird if only you had this issue.


This code is being called when a contact is about to be removed from a campaign. Do you have some “Change membershi” event in some of your campaigns?

Are you able to batch remove contacts from a campaign in the contact list (table) view by checking a couple of contacts and selecting the change campaign membership option in the table context menu?

I recently had the same issue while updating segments on Mautic 4.4.10, PHP 8.0.30, and MySQL 8.0.35.

@escopecz I don’t understand the suggested action since I’m new to Mautic. Also, can you please explain when this could happen so I can prevent facing this issue? I prefer not to use any manual actions in the future if it’s possible.


I was asking if this operation works if you have that issue on contact list page:

Also what version of mysql or mariadb do you use?

@escopecz It’s MySQL 8.0.33. I accidentally wrote 8.0.35 earlier.

I can’t try what you suggest because this is happening in production, and I don’t know which contacts may cause the issue. I will try to replicate it on the stage server. I would appreciate it if you could explain how this could happen.


I have no idea how this could happen. My candidates were:

  1. Old Mysql version that do not support the REPLACE INTO queries but you use a version that supports that.
  2. The prepared statements weren’t replaced, but I have no idea why it wouldn’t work for this query and would work for others.

Could you check what DB driver do you use? Please check your app/confilg/local.php config file and tell us what value you use for db_driver option.

The value of the db_driver key is mysqli.

That may be the issue. As more people using mysqli are having issues and supporting this driver 100% would require a lot of work, we are removing it in

All Mautic instances will start using the pdo_mysql driver since Mautic 5.0.2 no matter what is in the configuration. For now, please change the db_driver from mysqli to pdo_mysql to test that that will solve your problem.

1 Like

This fixed the issue for me. Thank you.