Firefox PHP

Fatal error in /include/db/mysql/mysqli.php

Posted by Ulf Dunkel 
Fatal error in /include/db/mysql/mysqli.php
October 19, 2023 09:31AM
Dear Phorum developers.

I have moved one of my Phorum installations to a new place and now I always run into this error:

Language: PHP
<b>Fatal error</b>: Uncaught mysqli_sql_exception: Duplicate entry ';hooks'; for key ';P5_iC_settings.PRIMARY'; in /<myserver>/phorum/include/db/mysql/mysqli.php:149

mysqli.php, line 149, reads:

Language: PHP
$res = mysqli_query($conn, $sql);

How can I fix this issue?

Regards, Ulf Dunkel
Re: Fatal error in /include/db/mysql/mysqli.php
October 20, 2023 02:03PM
Backup the database.

Quote

Duplicate entry ';hooks';
for key ';P5_iC_settings.PRIMARY';
I believe a primary key must be "unique" entry.

Disable mods and see if the issue goes away.
Turn the mods back on one at a time and test.
Try rebuilding the tables using mysql maintenance utility.
Re: Fatal error in /include/db/mysql/mysqli.php
June 13, 2024 09:20AM
I have no idea how to disable used mods for the phorum as I cannot access any phorum pages on my browser right now. I have access to the MySQL database though.

This is the whole error message:

Language: HTML
<!-- Fatal error: Uncaught mysqli_sql_exception: Duplicate entry `hooks´ for key `phorum_settings.PRIMARY´ in /phorum/include/db/mysql/mysqli.php:149 Stack trace: #0 /phorum/include/db/mysql/mysqli.php(149): mysqli_query() #1 /phorum/include/db/mysql.php(426): phorum_db_interact() #2 /phorum/include/api/modules.php(492): phorum_db_update_settings() #3 /phorum/include/admin/header.php(174): phorum_api_modules_save() #4 /phorum/admin.php(108): include_once(...) #5 {main} thrown in /phorum/include/db/mysql/mysqli.php on line 149 -->

I did not manipulate any Phorum database tables or data myself already.

Please help.

Regards, Ulf Dunkel
Re: Fatal error in /include/db/mysql/mysqli.php
July 22, 2024 06:34AM
I found a solution myself and like to share it with others:

- Because I had no chance to access my Phorum's admin interface, I simply renamed the mods folder on my server to mods_OFF. That didn't help in the first place.

Then I emptied the whole cache folder and voilà - the Phorum pages showed up properly again.

Then I created a new mods folder and copied the mods one by one, checking which ones caused problems. These are the modules I then switched off (by renaming their folders):

  • bbcode_OFF (2.0.12)
  • event_logging_OFF_SLOW (5.2.13)
  • filelist_OFF_SLOW (1.1.4)
  • onlineusers_OFF (2.4.3)
  • spamhurdles_OFF (2.0.2)

Now the Phorum can be accessed again. I have listed my versions of these critical mods just in case someone could explain why these do no longer work with my Phorum installation v 5.2.23.

I still cannot access the Phorum's admin page again, no matter if I have any mods activated or not. This is the current error list:

Language: PHP
<b>Fatal error</b>: Uncaught mysqli_sql_exception: Duplicate entry ';hooks'; for key ';phorum_settings.PRIMARY'; in /phorum/include/db/mysql/mysqli.php:149 Stack trace: #0 /phorum/include/db/mysql/mysqli.php(149): mysqli_query() #1 /phorum/include/db/mysql.php(426): phorum_db_interact() #2 /phorum/include/api/modules.php(492): phorum_db_update_settings() #3 /phorum/include/admin/header.php(174): phorum_api_modules_save() #4 /phorum/admin.php(108): include_once(';...';) #5 {main} thrown in <b>/phorum/include/db/mysql/mysqli.php</b> on line <b>149</b>

Best, UIf

Regards, Ulf Dunkel
Re: Fatal error in /include/db/mysql/mysqli.php
September 28, 2024 07:04AM
Try
MariaDB [phorum]> select * from phorum_settings where name = 'hooks';
If you get more than one row, something has gone very wrong with your database. In that case try
MariaDB [phorum]> describe phorum_settings;
Column 'name' should be Null=NO, Key=PRI. If Key=PRI is missing, it explains how you could get more than one row with name=hooks.

Check the data column of your 'hooks' rows and compare them to one-another. That might reveal where they came from.

Once you understand what happened and how, you will have to repair the database without losing data. Your best bet is probably to dump the database (use --extended-insert=FALSE), manually edit the dump to delete the surplus 'hooks', load the edited dump back into the database, add Null=NO, Key=PRI to name if needed, and then attempt to reinstall the mods or reconfigure the settings that appeared in the hooks rows that you deleted from the dump.
Re: Fatal error in /include/db/mysql/mysqli.php
October 14, 2024 04:01AM
Thank you for your detailed reply.

I only have one 'hooks' row and the 'describe phorum_settings' command shows data as mentioned by you. So I guess my issue sticks somewhere else. What else could I try instead?

Regards, Ulf Dunkel
Re: Fatal error in /include/db/mysql/mysqli.php
October 17, 2024 11:38AM
Quote
Scott Finegan
Try rebuilding the tables using mysql maintenance utility.

Where do I find the mentioned mysql maintenance utility, please?

Regards, Ulf Dunkel
Re: Fatal error in /include/db/mysql/mysqli.php
October 17, 2024 06:29PM
Please note, I have not used these is several years, so I don't know what is up to date.

Mysql workbench manual [dev.mysql.com]
phpmyadmin third party [www.phpmyadmin.net]

There may be others... Google mysql utilities

Some hosts make phpmyadmin available in the website control console.



Edited 1 time(s). Last edit at 10/17/2024 06:32PM by Scott Finegan.
Re: Fatal error in /include/db/mysql/mysqli.php
October 18, 2024 02:42AM
Thank you, Scott. I checked everything with my phpmyadmin maintenance tools and it reports that all tables are fine so far.

I guess I'm lost using PHORUM with PHP 8 as long as no developers are maintaining the PHORUM source code any longer.

Regards, Ulf Dunkel
Re: Fatal error in /include/db/mysql/mysqli.php
October 18, 2024 09:35AM
Back before covid, I was going to go through the code and fix the issues with php 8.x.
Due to family medical issues, that was put on hold, where it remains.

[www.a2hosting.com] Still offers older versions of php.
This phorum is hosted with A2.
Re: Fatal error in /include/db/mysql/mysqli.php
October 22, 2024 02:14PM
Thanks for your honest and quick reply, Scott. I totally understand this.

But I cannot go back to older PHP versions for several reasons.

I'd be more than happy if you find some spare time to fix the PHP issues with PHP 8 (hopefully before PHP 9 is released).

Best, Ulf

Regards, Ulf Dunkel
Sorry, only registered users may post in this forum.

Click here to login