FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » How to prevent division by zero error
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
How to prevent division by zero error [message #37491] Tue, 29 May 2007 17:34 Go to next message
derek is currently offline  derek   United Kingdom
Messages: 21
Registered: May 2007
Karma: 0
Junior Member
Hello,

I don't think this can be a bug, hence my posting here - hope this is OK. I've searched and seen similar divide by zero problems but I can't see this particular one, and I can't relate the answers I've seen to my specific problem.

Having upgraded to 2.7.6 a few hours ago, all seems OK except when adding a new topic or posting a reply, when users get this message:

Warning: Division by zero in [path]/docs/forum/theme/default/post.php on line 2270

Have I set something to zero that I shouldn't have?

Thanks for any advice...

Derek
Re: How to prevent division by zero error [message #37494 is a reply to message #37491] Tue, 29 May 2007 20:18 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Can you attach post.php please?

FUDforum Core Developer
Re: How to prevent division by zero error [message #37499 is a reply to message #37494] Wed, 30 May 2007 06:53 Go to previous messageGo to next message
derek is currently offline  derek   United Kingdom
Messages: 21
Registered: May 2007
Karma: 0
Junior Member
OK it's attached.

Thanks,

Derek
  • Attachment: post.php
    (Size: 168.28KB, Downloaded 1001 times)
Re: How to prevent division by zero error [message #37503 is a reply to message #37499] Wed, 30 May 2007 18:34 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Looks like your admin setting of "Message icons per row" is set to 0, which is what's causing the problem.

FUDforum Core Developer
Re: How to prevent division by zero error [message #37515 is a reply to message #37503] Thu, 31 May 2007 10:39 Go to previous messageGo to next message
derek is currently offline  derek   United Kingdom
Messages: 21
Registered: May 2007
Karma: 0
Junior Member
Thank you very much. I changed this to a number higher than zero (I was trying not to show any icons, but obviously this is not how to achieve that), went back to the forum and was able to post without the divide by zero error.

However, and I can't say whether this is connected or not, now when users try to log in they get this message:

Quote:

Warning: pg_query() [function.pg-query]: Query failed: ERROR: Argument of OR must be type boolean, not type integer in [path]/docs/forum/index.php on line 95

Fatal error: SQL Error has occurred, please contact the administrator of the forum and have them review the forum's SQL query log in [path]/FUDforum/include/core.inc on line 188


The sql_errors file has this (I'm using postgres):

Quote:

?1429 ?1180600719?([path]/docs/forum/index.php:95<br />
[path]/docs/forum/index.php:89<br />
[path]/docs/forum/theme/default/index.php:151<br />
[path]/docs/forum/index.php:1219<br />
) : ERROR: Argument of OR must be type boolean, not type integer<br />
Query: SELECT
m.subject, m.id, m.post_stamp,
u.id, u.alias,
f.cat_id, f.forum_icon, f.id, f.last_post_id, f.moderators, f.name, f.descr, f.post_count, f.thread_count,
fr.last_view, mo.id, COALESCE(g2.group_cache_opt, g1.group_cache_opt) AS group_cache_opt,
c.cat_opt &amp; 4
FROM fud25_fc_view v
INNER JOIN fud25_cat c ON c.id=v.c
INNER JOIN fud25_forum f ON f.id=v.f
INNER JOIN fud25_group_cache g1 ON g1.user_id=2147483647 AND g1.resource_id=f.id
LEFT JOIN fud25_msg m ON f.last_post_id=m.id
LEFT JOIN fud25_users u ON u.id=m.poster_id LEFT JOIN fud25_forum_read fr ON fr.forum_id=f.id AND fr.user_id=9 LEFT JOIN fud25_mod mo ON mo.user_id=9 AND mo.forum_id=f.id LEFT JOIN fud25_group_cache g2 ON g2.user_id=9 AND g2.resource_id=f.id WHERE (mo.id IS NOT NULL OR (COALESCE(g2.group_cache_opt, g1.group_cache_opt)) &amp; 1)&gt;0 ORDER BY v.id<br />
_GET: array (
'S' =&gt; 'd3a34e44ffaf72b0bd2b6a6a77aaabe0',
'SQ' =&gt; '727735018baf0ff543f3998f0c220d62',
)<br />
Server Version: <br />


I see the problem reported here:

http://fudforum.org/forum/index.php?t=msg&goto=33770&&srch=Quer y+failed#msg_33770

but does this mean that the wrong version of index.php is being distrubuted with the upgrade? Can you confirm what/where the final version is, so I can copy it over the one I installed (or do I have to edit it to add in the corrected lines?)

Thanks again,

Derek
Re: How to prevent division by zero error [message #37523 is a reply to message #37515] Thu, 31 May 2007 18:07 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
You need to replace c.cat_opt & 4 with (c.cat_opt & 4) = 4

FUDforum Core Developer
Re: How to prevent division by zero error [message #37527 is a reply to message #37523] Fri, 01 June 2007 11:23 Go to previous messageGo to next message
derek is currently offline  derek   United Kingdom
Messages: 21
Registered: May 2007
Karma: 0
Junior Member
I've only found the code

Quote:

c.cat_opt & 4


in src/index.php.t (apart from in errors/sql_errors where it is 'c.cat_opt &amp; 4')

So is it in src/index.php.t that this code needs to be replaced with

Quote:

(c.cat_opt & 4) = 4


or am I missing this code completely from the file it should be in - docs/forum/index.php possibly?

Thanks
Re: How to prevent division by zero error [message #37546 is a reply to message #37527] Sun, 03 June 2007 15:09 Go to previous messageGo to next message
Ilia is currently offline  Ilia   
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
You need to make the replacement inside index.php.t and then rebuild the theme via the theme manager. That will regenerate index.php page.

FUDforum Core Developer
Re: How to prevent division by zero error [message #37602 is a reply to message #37546] Thu, 07 June 2007 12:45 Go to previous messageGo to next message
derek is currently offline  derek   United Kingdom
Messages: 21
Registered: May 2007
Karma: 0
Junior Member
OK did that but no effect on the problem - same
Quote:

Warning: pg_query() [function.pg-query]: Query failed: ERROR: Argument of OR must be type boolean, not type integer in [path]/docs/forum/index.php on line 95

Fatal error: SQL Error has occurred, please contact the administrator of the forum and have them review the forum's SQL query log in [path]/FUDforum/include/core.inc on line 188

message.

However it only seems to be an issue when a user tries log in while already logged in (ie via another window or browser).

Re: How to prevent division by zero error [message #37607 is a reply to message #37602] Fri, 08 June 2007 00:57 Go to previous messageGo to next message
Ilia is currently offline  Ilia   
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Did you rebuild the theme after applying the patch?

FUDforum Core Developer
Re: How to prevent division by zero error [message #37610 is a reply to message #37607] Fri, 08 June 2007 07:53 Go to previous messageGo to next message
derek is currently offline  derek   United Kingdom
Messages: 21
Registered: May 2007
Karma: 0
Junior Member
After I changed 'c.cat_opt & 4' to '(c.cat_opt & 4) = 4', I then rebuilt the theme via the theme manager. Is there a before/after bit of code I can check in the regenerated index.php page to confirm?

I'm now using the forum 'as is' (I had disabled it over the last week) as I can tell users who get this message to clear their cookies and re-start their browser to log in again. Not ideal, but it will do - the alternative was going back to a previous (stable) version and all the hassle that would involve,

Previously I'd asked

Quote:

but does this mean that the wrong version of index.php is being distrubuted with the upgrade


but I suppose this is not something others have a problem with, and 2.7.6 is a 'stable' version, so I'm bemused by the problems I'm experiencing.

Anyway thanks for your tips (it has always 'just worked' for me before) and if there is any further light you can shed on this issue I'd be grateful.

Regards
Re: How to prevent division by zero error [message #37630 is a reply to message #37610] Mon, 11 June 2007 02:01 Go to previous message
Ilia is currently offline  Ilia   
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Can you tell me what precisely is the query error now from the forum's error log please?

FUDforum Core Developer
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: disbale unknow/unconfirmed user to enter forum
Next Topic: rebuild search index timing out
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 09:43:02 GMT 2024

Total time taken to generate the page: 0.03282 seconds