Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 DEV-Group
 DEV Bug Reports (Closed)
 Type mismatch when archiving
 Forum Locked  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

cripto9t
Average Member

USA
881 Posts

Posted - 06 December 2006 :  06:42:32  Show Profile
Technical Information (for support personnel)

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch
/snitz/snitzQuiz/admin_forums.asp, line 805


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) 

Page:
GET /snitz/snitzQuiz/admin_forums.asp 

Time:
Wednesday, December 06, 2006, 5:35:43 AM

condition
Attempted to archive topics in a single forum over 1 month old (no topics met this condition).

database: mysql 5.0

Sum not coming out as integer in mySql 5.0
My fix in red

		'## Forum_SQL - Count total number of Archived Replies
		strSql = "SELECT Sum(" & strTablePrefix & "A_TOPICS.T_REPLIES) AS SumOfT_A_REPLIES, Count(" & strTablePrefix & "A_TOPICS.T_REPLIES) AS cnt "
		strSql = strSql & " FROM " & strTablePrefix & "A_TOPICS "
		strSql = strSql & " WHERE " & strTablePrefix & "A_TOPICS.FORUM_ID = " & rs("FORUM_ID")
	
		rs1.Open strSql, my_Conn

		if rs1.EOF or rs1.BOF then
			intF_A_COUNT = 0
			intF_A_TOPICS = 0
		else
			intF_A_COUNT = rs1("cnt") + cLng(rs1("SumOfT_A_REPLIES"))
			intF_A_TOPICS = rs1("cnt") 
		end if
		if IsNull(intF_A_COUNT) then intF_A_COUNT = 0 
		if IsNull(intF_A_TOPICS) then intF_A_TOPICS = 0 

		rs1.Close
<

    _-/Cripto9t\-_

Edited by - AnonJr on 17 March 2009 19:11:35

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 06 December 2006 :  06:56:56  Show Profile
To be consistent and in case MySQL change the way COUNT is returned in future releases, I'd go for:

'## Forum_SQL - Count total number of Archived Replies
strSql = "SELECT Sum(" & strTablePrefix & "A_TOPICS.T_REPLIES) AS SumOfT_A_REPLIES, Count(" & strTablePrefix & "A_TOPICS.T_REPLIES) AS cnt "
strSql = strSql & " FROM " & strTablePrefix & "A_TOPICS "
strSql = strSql & " WHERE " & strTablePrefix & "A_TOPICS.FORUM_ID = " & rs("FORUM_ID")

rs1.Open strSql, my_Conn

if rs1.EOF or rs1.BOF then
intF_A_COUNT = 0
intF_A_TOPICS = 0
else
intF_A_COUNT = clng(rs1("cnt")) + cLng(rs1("SumOfT_A_REPLIES"))
intF_A_TOPICS = clng(rs1("cnt"))
end if
if IsNull(intF_A_COUNT) then intF_A_COUNT = 0
if IsNull(intF_A_TOPICS) then intF_A_TOPICS = 0

rs1.Close

We could probably also remove the checks for intF_A_COUNT and intF_A_TOPICS being null at the end of that block of code.

<

Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”

Edited by - Shaggy on 06 December 2006 06:57:10
Go to Top of Page

cripto9t
Average Member

USA
881 Posts

Posted - 03 September 2007 :  11:05:15  Show Profile
quote:
We could probably also remove the checks for intF_A_COUNT and intF_A_TOPICS being null at the end of that block of code

Nope, we still need to check for null.
I just got an "invalid use fo null" error. So heres a new fix.
Again this is for mySql. My version is 5.0.37.
if rs1.EOF or rs1.BOF then
			intF_COUNT = 0
			intF_TOPICS = 0
		else
                        if IsNull(rs1("cnt")) then 
                                tmpCnt = 0
                        else
                                tmpCnt = cLng(rs1("cnt"))
                        end if
                       
		        if IsNull(rs1("SumOfT_REPLIES")) then 
                                tmpSum = 0 
                        else
                                tmpSum = cLng(rs1("SumOfT_REPLIES"))
                        end if
                        
		        intF_COUNT = tmpCnt + tmpSum
                        intF_TOPICS = tmpCnt 
		end if

And for archives
if rs1.EOF or rs1.BOF then
			intF_A_COUNT = 0
			intF_A_TOPICS = 0
                else
                        if IsNull(rs1("cnt")) then 
                                tmpACnt = 0
                        else
                                tmpACnt = cLng(rs1("cnt"))
                        end if
                       
		        if IsNull(rs1("SumOfT_A_REPLIES")) then 
                                tmpASum = 0 
                        else
                                tmpSumA = cLng(rs1("SumOfT_A_REPLIES"))
                        end if
                        
		        intF_A_COUNT = tmpACnt + tmpASum
                        intF_A_TOPICS = tmpACnt 
		end if
<

    _-/Cripto9t\-_
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 05 December 2007 :  14:54:46  Show Profile
This needs more testing before implementing your suggested fix. Would need to make sure the fix also works with the latest stable version of mysql server version 4.

I have version 4.0.26 and getting errors archiving as well. Need someone with version 5.0 to test too.<

Support Snitz Forums
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 07 January 2008 :  20:46:56  Show Profile
Here is the fix for this.

Lines 804 - 807 was changed from this:
else
	intF_COUNT = rs1("cnt") + rs1("SumOfT_REPLIES")
	intF_TOPICS = rs1("cnt") 
end if
to this:
else
	if IsNull(rs1("SumOfT_REPLIES")) then
		intF_COUNT = rs1("cnt")
	else
		intF_COUNT = CLng(rs1("cnt")) + CLng(rs1("SumOfT_REPLIES"))
	end if
	intF_TOPICS = rs1("cnt") 
end if


Lines 823 - 826 changed from this:
else
	intF_A_COUNT = rs1("cnt") + rs1("SumOfT_A_REPLIES")
	intF_A_TOPICS = rs1("cnt") 
end if
to this:
else
	if IsNull(rs1("SumOfT_A_REPLIES")) then
		intF_A_COUNT = rs1("cnt")
	else
		intF_A_COUNT = CLng(rs1("cnt")) + CLng(rs1("SumOfT_A_REPLIES"))
	end if
	intF_A_TOPICS = rs1("cnt") 
end if


Lines 862-863 changed from this:
Response.Write "Total Topics: " & RS("SumOfF_TOPICS") & "<br />" & vbNewline
strSumOfF_TOPICS = rs("SumOfF_TOPICS")
to this:
if IsNull(RS("SumOfF_TOPICS")) then
	Response.Write "Total Topics: 0<br />" & vbNewline
	strSumOfF_TOPICS = 0
else
	Response.Write "Total Topics: " & RS("SumOfF_TOPICS") & "<br />" & vbNewline
	strSumOfF_TOPICS = rs("SumOfF_TOPICS")
end if


Lines 874-875 changed from this:
Response.Write "Total Archived Topics: " & RS("SumOfF_A_TOPICS") & "<br />" & vbNewline
strSumOfF_A_TOPICS = rs("SumOfF_A_TOPICS")
to this:
if IsNull(RS("SumOfF_A_TOPICS")) then
	Response.Write "Total Archived Topics: 0<br />" & vbNewline
	strSumOfF_A_TOPICS = 0
else
	Response.Write "Total Archived Topics: " & RS("SumOfF_A_TOPICS") & "<br />" & vbNewline
	strSumOfF_A_TOPICS = rs("SumOfF_A_TOPICS")
end if
<

Support Snitz Forums
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 07 January 2008 :  20:49:27  Show Profile
cripto9t, this was similar to your fix, so it should work. If you (or anyone else) have any problems after using the fix, email me and let me know.

Fixed in version 3.4.07.<

Support Snitz Forums
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000 Version 3.4.07