MyBB Community Forums

Full Version: internal SQL error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey everyone. Something happened, suddenly, out of nowhere literally. It was working fine when I've started seeing this error, don't know what caused it. When I'm logged in, I can access anywhere except admin cp and a user's profile (only got 1 test user). When I'm logged out, I still can't get in admin cp and user's profile, and can't get in the thread where I posted with the test account. Here's the error log:

<error>
	<dateline>1626819708</dateline>
	<script>inc/functions.php</script>
	<line>1460</line>
	<type>2</type>
	<friendly_type>Warning</friendly_type>
	<message>in_array() expects parameter 2 to be array, null given</message>
	<back_trace>#0  errorHandler->error() called at [[PHP]: ]
#1  in_array() called at [/inc/functions.php:1460]
#2  usergroup_permissions() called at [/inc/functions.php:1358]
#3  user_permissions() called at [/member.php:2041]
</back_trace>
</error>

<error>
	<dateline>1626819708</dateline>
	<script>inc/functions.php</script>
	<line>1466</line>
	<type>2</type>
	<friendly_type>Warning</friendly_type>
	<message>array_key_exists() expects parameter 2 to be array, null given</message>
	<back_trace>#0  errorHandler->error() called at [/inc/functions.php:1466]
#1  usergroup_permissions() called at [/inc/functions.php:1358]
#2  user_permissions() called at [/member.php:2041]
</back_trace>
</error>

<error>
	<dateline>1626819708</dateline>
	<script>inc/functions.php</script>
	<line>1480</line>
	<type>2</type>
	<friendly_type>Warning</friendly_type>
	<message>array_key_exists() expects parameter 2 to be array, null given</message>
	<back_trace>#0  errorHandler->error() called at [/inc/functions.php:1480]
#1  usergroup_permissions() called at [/inc/functions.php:1358]
#2  user_permissions() called at [/member.php:2041]
</back_trace>
</error>

<error>
	<dateline>1626819708</dateline>
	<script></script>
	<line>0</line>
	<type>20</type>
	<friendly_type>MyBB SQL Error</friendly_type>
	<message>SQL Error: 2006 - MySQL server has gone away
Query: SELECT location,nopermission FROM mfdkpwr_sessions WHERE uid='2' AND time>'1626818808' ORDER BY time DESC LIMIT 1</message>
	<back_trace>#0  errorHandler->error() called at [/inc/db_mysqli.php:601]
#1  DB_MySQLi->error() called at [/inc/db_mysqli.php:337]
#2  DB_MySQLi->query() called at [/inc/db_mysqli.php:793]
#3  DB_MySQLi->simple_select() called at [/member.php:2433]
</back_trace>
</error>


Hope to get some help because I've tried lots of stuff but still no luck.

<error>
	<dateline>1626867811</dateline>
	<script>inc/functions.php</script>
	<line>1480</line>
	<type>2</type>
	<friendly_type>Warning</friendly_type>
	<message>array_key_exists() expects parameter 2 to be array, null given</message>
	<back_trace>#0  errorHandler->error() called at [/inc/functions.php:1480]
#1  usergroup_permissions() called at [/inc/functions.php:1358]
#2  user_permissions() called at [/inc/functions_post.php:716]
#3  build_postbit() called at [/showthread.php:1117]
</back_trace>
</error>

<error>
	<dateline>1626867811</dateline>
	<script>inc/functions.php</script>
	<line>1460</line>
	<type>2</type>
	<friendly_type>Warning</friendly_type>
	<message>in_array() expects parameter 2 to be array, null given</message>
	<back_trace>#0  errorHandler->error() called at [[PHP]: ]
#1  in_array() called at [/inc/functions.php:1460]
#2  usergroup_permissions() called at [/inc/functions.php:1358]
#3  user_permissions() called at [/inc/functions_post.php:716]
#4  build_postbit() called at [/showthread.php:1117]
</back_trace>
</error>

<error>
	<dateline>1626867811</dateline>
	<script>inc/functions.php</script>
	<line>1466</line>
	<type>2</type>
	<friendly_type>Warning</friendly_type>
	<message>array_key_exists() expects parameter 2 to be array, null given</message>
	<back_trace>#0  errorHandler->error() called at [/inc/functions.php:1466]
#1  usergroup_permissions() called at [/inc/functions.php:1358]
#2  user_permissions() called at [/inc/functions_post.php:716]
#3  build_postbit() called at [/showthread.php:1117]
</back_trace>
</error>

<error>
	<dateline>1626867811</dateline>
	<script></script>
	<line>0</line>
	<type>20</type>
	<friendly_type>MyBB SQL Error</friendly_type>
	<message>SQL Error: 2006 - MySQL server has gone away
Query: SELECT url, url_term FROM mfdkpwr_urls WHERE url IN ('')</message>
	<back_trace>#0  errorHandler->error() called at [/inc/db_mysqli.php:601]
#1  DB_MySQLi->error() called at [/inc/db_mysqli.php:337]
#2  DB_MySQLi->query() called at [/inc/db_mysqli.php:793]
#3  DB_MySQLi->simple_select() called at [/inc/plugins/linktools.php:4013]
#4  lkt_retrieve_terms() called at [/inc/plugins/linktools.php:3924]
#5  lkt_insert_preview_placeholders() called at [/inc/plugins/linktools.php:3903]
#6  lkt_hookin__parse_message_start() called at [/inc/class_plugins.php:142]
#7  pluginSystem->run_hooks() called at [/inc/class_parser.php:153]
#8  postParser->parse_message() called at [/inc/functions_post.php:810]
#9  build_postbit() called at [/showthread.php:1117]
</back_trace>
</error>


Different(?) errors while I'm in my test account. Every aspect of the site, as I mentioned earlier, works. I can open new threads, post new replies, send PMs etc. etc. But I can't get into any thread that contains a post from a different member than I'm currently logged in, I can't get into their profile (can get into mine) and I can't get into admin CP no matter what. Also, I'd like to mention that I've not even touched any specified files above. Disabling plugins won't do anything.
What MyBB version are you running? Does the ACP's Tools & Maintenance → File Verification show any issues?
(2021-07-21, 03:31 PM)Devilshakerz Wrote: [ -> ]What MyBB version are you running? Does the ACP's Tools & Maintenance → File Verification show any issues?

Freshly installed 1.8.27. I can't get in ACP so never checked if file verification show any issues. I just installed some plugins (that I've installed all of my projects, nothing unusal) and I was editing default MyBB theme, as I always do. But when I first saw this error, I was not altering anything. It's like one minute ago everything was just fine and then something happened. I would've taken back what I did if only I did something, like changing a setting, deleting/altering a file, installing a new plugin etc. etc. because I always got my backups before doing something but as I said, I was just checking out some pages and suddenly it started to give me error. Contacted my hosting provider if it's something to do with them by the way.
Try overwriting MyBB's files with the 1.8.27 full package (inc/class_core.php and inc/functions.php in particular seem to be out of order, but there may be more).
(2021-07-21, 04:20 PM)Devilshakerz Wrote: [ -> ]Try overwriting MyBB's files with the 1.8.27 full package (inc/class_core.php and inc/functions.php in particular seem to be out of order, but there may be more).

After I overwrote the original inc folder (except for settings.php and config.php), it did solve the problem, weird. But could you please tell me your opinion, what may have caused this problem as I've not done anything "wrong" and how can I prevent it to happen in the future and if it's a temporary solution and I may experience the same thing again?
Was it definitely 1.8.27 you uploaded the files for? The line number in your error didn't match what's in the code for 1.8.27 so it looked like an older version of the file.
(2021-07-21, 09:13 PM)Matt Wrote: [ -> ]Was it definitely 1.8.27 you uploaded the files for? The line number in your error didn't match what's in the code for 1.8.27 so it looked like an older version of the file.

I'm 100% sure. Because I downloaded 1.8.27 files and I have the same .rar since the date I downloaded for the first time because I freshly installed just a week ago and when I replaced inc folder with the original ones, I've used the same rar that I've installed my forum a week ago. And I've never not touched those files as I don't even have a previous version of MyBB in my PC. Besides, when I started getting these errors, I've not made any alterations, it just happened, I wasn't even connected to FTP. If I'd have somehow changed them with older versions, I'd have gotten these errors when I did but forum worked like a charm for a week and haven't worked on it for two days and getting these errors surprised me as I've not done anything and it's not the first time I'm working with MyBB. The weird part is that I was just surfing through my forum, everything was working just fine and I was in Admin CP, changed a really few and simples settings like the board name etc. in "Site Details" and in "General Configuration" and I got into "Server and Optimization Options", changed few things and hit "Save Settings" and it took a quite a while to load the and I understood that something's wrong and it gave me the MySQL error, which was a surprise. But long story short, you're of course somehow right because I've just compared them and they're two different files. I don't know why or how. If you want to investigate this further, I can upload them both for you to take a closer look at it.
Some plugins may also modify core files to enable certain functionality.

You can use a comparison tool to compare between modified and original files (we also have a plugin to compare current forum files against original ones), or upload the reported modified files here.