Hi,

I've had SQL errors appearing when I'm managing forums on a board (enabling and disabling forums), and each time I get SQL errors of the form:
Code
[b]Script:[/b] .\forums\admin\doforummanage.php
[b]Line#:[/b] 94
[b]SQL Error:[/b] Incorrect integer value: '' for column 'FORUM_SORT_ORDER' at row 1
[b]SQL Error #:[/b] 1366
[b]Query:[/b] UPDATE ubbt_FORUMS SET FORUM_TITLE = '',FORUM_SORT_ORDER='' WHERE FORUM_ID='360'

Now, this has been benign in the past (i.e. didn't affect functionality), but has now started to prevent us from disabling forums.

I'm running on 7.5.6p2, and I can't imagine that I'm the first person that came across this issue, but I can't find anything on the board about it.

Looking at the source code, I've seen that the "admin/doforummanage.php" file doesn't look particularly efficient (for every forum in the database, it (re-)fetches all of the forum data posted back to the script), nor does it check if the forum found in the database had any data posted back to it by the page.

The code for 7.5.7 hasn't changed in this respect either.

I've modified the code to get the forum data being posted back to the page once only, and to check if the forum found from the SQL query is in the forum data that was posted back, ignoring any forums that are not in the forum data being posted back. This is the context-patch:-
Code
*** ./ubbthreads-7-5-7/admin/doforummanage.php	Tue Jul 02 09:39:07 2013
--- ./forums/admin/doforummanage.php	Tue Jul 02 14:44:03 2013
***************
*** 31,41 ****
  	$forums[$i]['active'] = $active;
  	$i++;
  }
- for ($x=0;$x<$i;$x++) {
- 	$fnum = $forums[$x]['number'];
  	$titles = get_input("forum","post");
  	$orders = get_input("order","post");
  	$active = get_input("active","post");
  	if (!isset($active[$fnum])) {
  		$active[$fnum] = '0';
  	}
--- 57,68 ----
  	$forums[$i]['active'] = $active;
  	$i++;
  }
  $titles = get_input("forum","post");
  $orders = get_input("order","post");
  $active = get_input("active","post");
+ for ($x=0;$x<$i;$x++) {
+ 	$fnum = $forums[$x]['number'];
+ 	if (array_key_exists( $fnum, $titles)) {
  		if (!isset($active[$fnum])) {
  			$active[$fnum] = '0';
  		}
***************
*** 66,71 ****
--- 93,99 ----
  				WHERE FORUM_ID='$fnum'
  			";
  			$dbh->do_query($query,__LINE__,__FILE__);
+ 		}
  	}
  }
  admin_log("FORUM_MANAGE","");

I suspect that the problem is caused by deleting forums, which we do periodically, with the code dealing with the deletions not actually deleting it properly from the database.

I'm still investigating that side of things. In the meantime, any feedback on this issue would be gratefully accepted.