# Log error: campaign\_lead\_event\_failed\_log - Need help please

**URL:** <https://forum.mautic.org/t/log-error-campaign-lead-event-failed-log-need-help-please/29266>\
**Category:** Product Support\
**Created:** [September 12, 2023, 6:52pm UTC](https://forum.mautic.org/t/log-error-campaign-lead-event-failed-log-need-help-please/29266 "2023-09-12T18:52:52Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bunce69](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/bunce69/32/143_2.png) [@bunce69](https://forum.mautic.org/u/bunce69)\
**Post date:** [September 12, 2023, 6:52pm UTC](https://forum.mautic.org/t/log-error-campaign-lead-event-failed-log-need-help-please/29266/1 "2023-09-12T18:52:53Z")

</div>

**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.

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [September 13, 2023, 11:10am UTC](https://forum.mautic.org/t/log-error-campaign-lead-event-failed-log-need-help-please/29266/2 "2023-09-13T11:10:35Z")

</div>

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

[https://github.com/mautic/mautic/blame/4.4/app/bundles/CampaignBundle/Entity/LeadEventLogRepository.php#L601](https://github.com/mautic/mautic/blame/4.4/app/bundles/CampaignBundle/Entity/LeadEventLogRepository.php#L601)

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?

---

<div class="post-metadata">

**Author:** ![stefan.bubalo](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@stefan.bubalo](https://forum.mautic.org/u/stefan.bubalo)\
**Post date:** [January 11, 2024, 11:09am UTC](https://forum.mautic.org/t/log-error-campaign-lead-event-failed-log-need-help-please/29266/3 "2024-01-11T11:09:53Z")

</div>

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.

Thanks.

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [January 11, 2024, 12:59pm UTC](https://forum.mautic.org/t/log-error-campaign-lead-event-failed-log-need-help-please/29266/4 "2024-01-11T12:59:28Z")

</div>

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

 ![Screenshot 2024-01-11 at 13.58.03](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/a/a06bac048239cb1b5ab788f4d76bc8d9cbe6148b.png)

Also what version of mysql or mariadb do you use?

---

<div class="post-metadata">

**Author:** ![stefan.bubalo](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@stefan.bubalo](https://forum.mautic.org/u/stefan.bubalo)\
**Post date:** [January 12, 2024, 8:59am UTC](https://forum.mautic.org/t/log-error-campaign-lead-event-failed-log-need-help-please/29266/5 "2024-01-12T08:59:16Z")

</div>

@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.

Thanks.

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [January 12, 2024, 9:54am UTC](https://forum.mautic.org/t/log-error-campaign-lead-event-failed-log-need-help-please/29266/6 "2024-01-12T09:54:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![stefan.bubalo](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@stefan.bubalo](https://forum.mautic.org/u/stefan.bubalo)\
**Post date:** [January 12, 2024, 2:19pm UTC](https://forum.mautic.org/t/log-error-campaign-lead-event-failed-log-need-help-please/29266/7 "2024-01-12T14:19:40Z")

</div>

The value of the `db_driver` key is `mysqli`.

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [January 12, 2024, 6:49pm UTC](https://forum.mautic.org/t/log-error-campaign-lead-event-failed-log-need-help-please/29266/8 "2024-01-12T18:49:15Z")

</div>

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

> <https://github.com/mautic/mautic/pull/13210>
>
> \<!-- ## Which branch should I use for my PR?
> 
> Assuming that:
> 
> a = current ma…jor release
> b = current minor release
> c = future major release
> 
> \* a.x for any features and enhancements (e.g. 5.x)
> \* a.b for any bug fixes (e.g. 4.4, 5.1)
> \* c.x for any features, enhancements or bug fixes with backward compatibility breaking changes (e.g. 5.x) --\>
> 
> | Q | A
> | -------------------------------------- | ---
> | Bug fix? (use the a.b branch) | \[\]
> | New feature/enhancement? (use the a.x branch) | \[\]
> | Deprecations? | \[\]
> | BC breaks? (use the c.x branch) | \[\]
> | Automated tests included? | \[\] 
> | Related user documentation PR URL | mautic/mautic-documentation#... 
> | Related developer documentation PR URL | mautic/developer-documentation#... 
> | Issue(s) addressed | Fixes #13186 
> 
> \<!--
> Additionally (see https://contribute.mautic.org/contributing-to-mautic/developer/code/pull-requests#work-on-your-pull-request):
> - Always add tests and ensure they pass.
> - Bug fixes must be submitted against the lowest maintained branch where they apply
> (lowest branches are regularly merged to upper ones so they get the fixes too.)
> - Features and deprecations must be submitted against the "4.x" branch.
> \--\>
> 
> \#### Description:
> 
> This PR:
> \* requires \`pdo\` in \`composer.json\`
> \* checks during a compilerpass if \`pdo\_mysql\` is an available driver, and throws an error if not
> \* removes the mysqli option from the installer
> \* hardcodes the \`pdo\_mysql\` driver when pressing the local parameters
> \* shows a comprehensive error on CLI and web to explain what's going on
> 
> !\[Screenshot 2024-01-12 at 17 29 25\](https://github.com/mautic/mautic/assets/3983285/da7dda36-ddc1-4c8e-99be-28a9ca8d5394)
> 
> \<!--
> Please write a short README for your feature/bugfix. This will help people understand your PR and what it aims to do. If you are fixing a bug and if there is no linked issue already, please provide steps to reproduce the issue here.
> \--\>
> 
> \#### Steps to test this PR:
> 
> \<!--
> This part is really important. If you want your PR to be merged, take the time to write very clear, annotated and step by step test instructions. Do not assume any previous knowledge - testers may not be developers.
> \--\>
> 1. Open this PR on Gitpod or pull down for testing locally (see docs on testing PRs \[here\](https://contribute.mautic.org/contributing-to-mautic/tester))
> 2. 
> 
> \<!--
> If you have any deprecations, list them here along with the new alternative.
> If you have any backwards compatibility breaks, list them here.
> \--\>

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.

---

<div class="post-metadata">

**Author:** ![stefan.bubalo](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@stefan.bubalo](https://forum.mautic.org/u/stefan.bubalo)\
**Post date:** [January 15, 2024, 3:23pm UTC](https://forum.mautic.org/t/log-error-campaign-lead-event-failed-log-need-help-please/29266/9 "2024-01-15T15:23:48Z")

</div>

This fixed the issue for me. Thank you.
