MyBB Community Forums

Full Version: Problem with STICKY Threads
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Just tried to delete a sticky thread from my forum and got this error:

mySQL error: 1264
Out of range value adjusted for column 'lastpost' at row 1
Query: UPDATE mybb_forums SET posts='0', threads='0' ,lastpost='', lastposter='', lastposttid='' WHERE fid='4'

Also get a similar error when trying to post a sticky thread??

Any ideas?

http://forums.pghostinguk.com/
What version of mySQL are you running?
MySQL 5.0.21-community-nt
Well unfortunately this is a mySQL 5 error. I personally haven't done a whole lot of testing with myBB to use all its features in the mySQL 5 code.

What happened in mySQL 5 was something known as strict mode. This has its advantages as well as its disadvantages. The disadvantage is pretty obvious, old mySQL 4 code won't work. This is because strict mode tends to be a lot stricter than older mySQL 4 code when it came to queries. For example, if there is a type mismatch, ie: data being entered is text and value for database table cell is int, it will return an out of range error. The good side is that it starts to finally create some sort of standard in mySQL whereas before there was none and coders were allowed more leniency.

Realistically this should be addressed in a patch either in their current version or in the 1.2 release which seems to be discussed here and there.

If you want I can try to duplicate the problem later and post back with how to change the query on that page to properly run that query. And if you want me to take a look at this, if you could, do me a favor and post back what file is generating that error (ie: what page is showing in your address bar).
When trying to post a STICKY thread the URL is: http://forums.pghostinguk.com/newthread.php

The error I get then is:
mySQL error: 1366
Incorrect integer value: '' for column 'fid' at row 1
Query: INSERT INTO mybb_moderatorlog (uid,dateline,fid,tid,action,ipaddress) VALUES ('1','1154637310','','','Thread stuck','82.32.222.133')
The value cannot blank. It has to be at least null. Now I am starting to see what the problem is with the query.

Let me take a look at this later and I will see what I can do to fix the problem. Hey if it works I will try to turn this into a bigger post and see if the myBB creators will turn it into an official update to prevent this from happening to anyone else.
Nice one thanks!!

I can delete the database and re-install using MySQL 4 - its not a problem really as it is a new forum so only has a few posts in it!!

Will wait to see if it can be fixed first though!!!!

Cheers again!!
Hi - yes, this is a confirmed problem with 1.1.x and MySQL 5 support. It is already fixed for 1.2.

If you wish to fix it for yourselves, here is another workaround for it:

Open inc/functions.php.

Find:
function logmod($data, $action="")
{
	global $mybb, $mybbuser, $db, $session;

	$time = time();
	$db->query("INSERT INTO ".TABLE_PREFIX."moderatorlog (uid,dateline,fid,tid,action,ipaddress) VALUES ('".$mybb->user['uid']."','$time','".$data['fid']."','".$data['tid']."','$action','".$session->ipaddress."')");
}

Replace with:
function logmod($data, $action="")
{
	global $mybb, $mybbuser, $db, $session;

	$time = time();
	$db->query("INSERT INTO ".TABLE_PREFIX."moderatorlog (uid,dateline,fid,tid,action,ipaddress) VALUES ('".$mybb->user['uid']."','$time','".intval($data['fid'])."','".intval($data['tid'])."','$action','".$session->ipaddress."')");
}
How about the original problem with deleting the sticky? Would that be the same to use the intval function to change the variable to an integer?

However, will that work for the lastposter variable? From the looks the code it won't because the $lastposter variable in that statement in functions.php seems to be returning the username instead of a corresponding number.
Argh, sorry - didn't notice that one.

You'd find:
		$lpadd = ",lastpost='".$lp['lastpost']."', lastposter='".$lp['lastposter']."', lastposttid='".$lp['tid']."'";

and replace it with:
		$lpadd = ",lastpost='".intval($lp['lastpost'])."', lastposter='".$lp['lastposter']."', lastposttid='".intval($lp['tid'])."'";
Pages: 1 2