MyBB Community Forums

Full Version: Constant 'Experienced an Error' Messages
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey, guys. I keep getting e-mail notifications that the database has experienced an error on a daily basis. I've been wanting to figure out what's going on, since I don't mess with SQL that often.

What needs to be done here to fix this issue? From the looks of it, it's affecting the private messages to some extent by virtue of read variables.

Any help on this would be appreciated.

Thanks in advance.
Your copy of MyBB running on REDACTED (https://site.domain) has experienced an error. Details of the error include:
---
Type: 20
File:  (Line no. 0)
Message
SQL Error: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'read = 1' at line 3
Query: 
			DELETE
			FROM mybbpm_notifications
			 WHERE read = 1
		
Back Trace: #0  errorHandler->email_error(20, Array ([error_no] => 1064,[error] => You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'read = 1' at line 3,[query] => 
			DELETE
			FROM mybbpm_notifications
			 WHERE read = 1
		), , 0) called at [/home/mybb/inc/class_error.php:195]
#1  errorHandler->error(20, Array ([error_no] => 1064,[error] => You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'read = 1' at line 3,[query] => 
			DELETE
			FROM mybbpm_notifications
			 WHERE read = 1
		)) called at [/home/mybb/inc/db_mysql.php:601]
#2  DB_MySQL->error(
			DELETE
			FROM mybbpm_notifications
			 WHERE read = 1
		) called at [/home/mybb/inc/db_mysql.php:337]
#3  DB_MySQL->query(
			DELETE
			FROM mybbpm_notifications
			 WHERE read = 1
		, 0, 1) called at [/home/mybb/inc/db_mysql.php:371]
#4  DB_MySQL->write_query(
			DELETE
			FROM mybbpm_notifications
			 WHERE read = 1
		) called at [/home/mybb/inc/db_mysql.php:995]
#5  DB_MySQL->delete_query(pm_notifications, read = 1) called at [/home/mybb/inc/tasks/fullpm.php:10]
#6  task_fullpm(Array ([tid] => 49,[title] => pm_notifications,[description] => All the full pm notifications that were read by the user will be deleted every 24 hours.,[file] => fullpm,[minute] => 0,[hour] => 0,[day] => *,[month] => *,[weekday] => *,[nextrun] => 1567382400,[lastrun] => 0,[enabled] => 1,[logging] => 1,[locked] => 1567299956)) called at [/home/mybb/inc/functions_task.php:90]
#7  run_task()
#8  call_user_func_array(run_task, Array ()) called at [/home/mybb/inc/functions.php:236]
#9  run_shutdown()
Whith mariadb, read is a reserved keyword, so you have an error if it's not protected.
You'll have to modify the inc/tasks/fullpm.php and protect the read fieldname in it.

Corrected file:
<?php

if (!defined('IN_MYBB')) {
	die('Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.');
}
function task_fullpm($task)
{
	global $db;
    
	if ($db->delete_query('pm_notifications', '`read` = 1')) {
		add_task_log($task, "All read full pm notifications are removed from the database");
	} else {
		add_task_log($task, "Nope, the database did not liked the mission 'remove all read full pm notifications'... Something went wrong :( PLEASE FIX :*(");
	}
}

A better solution is to modify the plugin and change this fieldname to a non-reserved one.
In addition, looks like you're using a plugin which has a custom task (./inc/tasks/fullpm.php). Actually you should contact the plugin author to fix it.
(2019-09-02, 09:06 AM)noyle Wrote: [ -> ]In addition, looks like you're using a plugin which has a custom task (./inc/tasks/fullpm.php). Actually you should contact the plugin author to fix it.

Yes, he uses Full PM and I just made a suggestion to the author in the plugin page.
(2019-09-02, 08:57 AM)Crazycat Wrote: [ -> ]Whith mariadb, read is a reserved keyword, so you have an error if it's not protected.
You'll have to modify the inc/tasks/fullpm.php and protect the read fieldname in it.

Corrected file:
<?php

if (!defined('IN_MYBB')) {
	die('Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.');
}
function task_fullpm($task)
{
	global $db;
    
	if ($db->delete_query('pm_notifications', '`read` = 1')) {
		add_task_log($task, "All read full pm notifications are removed from the database");
	} else {
		add_task_log($task, "Nope, the database did not liked the mission 'remove all read full pm notifications'... Something went wrong :( PLEASE FIX :*(");
	}
}

A better solution is to modify the plugin and change this fieldname to a non-reserved one.
Seems like that might be the culprit. Thanks.