Author |
Topic |
davide.lorenzi
Starting Member
12 Posts |
Posted - 18 April 2007 : 04:44:25
|
I'm referring to functions doUCount() and doULastPost(). I checked these functions because I discovered that my forum never updated the topic count for a certain user. Debugging the function I see the VarType(sUser) is equal to 5 so the function makes an update on the DB using the "strSql" variable already called on a previous function because it cannot find a good condition!
The original code from version 3.4.06:
quote:
sub doUCount(sUser) if VarType(sUser) = 8 then 'Update using member username '## Forum_SQL - Update Total Post for user strSql = "UPDATE " & strMemberTablePrefix & "MEMBERS " strSql = strSql & " SET M_POSTS = M_POSTS + 1 " strSql = strSql & " WHERE " & strDBNTSQLName & " = '" & ChkString(sUser, "SQLString") & "'" elseif VarType(sUser) = 2 or VarType(sUser) = 3 then 'Update count using member id '## Forum_SQL - Update Total Post for user strSql = "UPDATE " & strMemberTablePrefix & "MEMBERS " strSql = strSql & " SET M_POSTS = M_POSTS + 1 " strSql = strSql & " WHERE MEMBER_ID = " & sUser end if my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords end sub
sub doULastPost(sUser) if VarType(sUser) = 8 then 'Update using member user name '## Forum_SQL - Updates the M_LASTPOSTDATE in the FORUM_MEMBERS table strSql = "UPDATE " & strMemberTablePrefix & "MEMBERS " strSql = strSql & " SET M_LASTPOSTDATE = '" & DateToStr(strForumTimeAdjust) & "' " strSql = strSql & " WHERE " & strDBNTSQLName & " = '" & ChkString(sUser, "SQLString") & "'" elseif VarType(sUser) = 2 or VarType(sUser) = 3 then 'Update using member id '## Forum_SQL - Updates the M_LASTPOSTDATE in the FORUM_MEMBERS table strSql = "UPDATE " & strMemberTablePrefix & "MEMBERS " strSql = strSql & " SET M_LASTPOSTDATE = '" & DateToStr(strForumTimeAdjust) & "' " strSql = strSql & " WHERE MEMBER_ID = " & sUser end if my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords end sub
The modified code should contain an "else" without "elseif" or the call Execute should be moved into the two conditional statements:
quote:
sub doUCount(sUser) if VarType(sUser) = 8 then 'Update using member username '## Forum_SQL - Update Total Post for user strSql = "UPDATE " & strMemberTablePrefix & "MEMBERS " strSql = strSql & " SET M_POSTS = M_POSTS + 1 " strSql = strSql & " WHERE " & strDBNTSQLName & " = '" & ChkString(sUser, "SQLString") & "'" else 'Update count using member id '## Forum_SQL - Update Total Post for user strSql = "UPDATE " & strMemberTablePrefix & "MEMBERS " strSql = strSql & " SET M_POSTS = M_POSTS + 1 " strSql = strSql & " WHERE MEMBER_ID = " & sUser end if my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords end sub
or (I've added the VarType()=5)
quote: sub doUCount(sUser) if VarType(sUser) = 8 then 'Update using member username '## Forum_SQL - Update Total Post for user strSql = "UPDATE " & strMemberTablePrefix & "MEMBERS " strSql = strSql & " SET M_POSTS = M_POSTS + 1 " strSql = strSql & " WHERE " & strDBNTSQLName & " = '" & ChkString(sUser, "SQLString") & "'" my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords elseif VarType(sUser) = 2 or VarType(sUser) = 3 or VarType(sUser) = 5 then 'Update count using member id '## Forum_SQL - Update Total Post for user strSql = "UPDATE " & strMemberTablePrefix & "MEMBERS " strSql = strSql & " SET M_POSTS = M_POSTS + 1 " strSql = strSql & " WHERE MEMBER_ID = " & sUser my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords
end if end sub
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 18 April 2007 : 04:53:44
|
How is a decimal number getting passed to those functions? The only way this can have happened is due to changes you've made elsewhere in your code - The only things that are ever be passed to that function in a clean install are a username (string) or a member ID (whole number).
|
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.” |
|
|
davide.lorenzi
Starting Member
12 Posts |
Posted - 18 April 2007 : 06:37:37
|
Yes, I agree with you but I've made no changes. Only the DB has been maintained from version 3.4.04.
The id is a simple Integer/Long, no decimal but the VarType is 5 :-( Have you tried to debug those functions? |
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 18 April 2007 : 06:44:26
|
Strangeness indeed ... Is this happening consistently for all members?
You did run setup.asp on database after upgrading to the latest version, right? What database type and version are you using?
|
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 18 April 2007 06:44:55 |
|
|
pdrg
Support Moderator
United Kingdom
2897 Posts |
Posted - 18 April 2007 : 06:54:29
|
Could be a nasty caused by the variant datatype (which everything inherently is in VBScript) - it's weak typing, and as all integers are faked anyway, maybe it's a legacy of that.
Would a well-placed cint() bring it back into line - it would fail for the text datatype, so the error could be captured on the following line.
Just a thought |
|
|
davide.lorenzi
Starting Member
12 Posts |
Posted - 18 April 2007 : 07:44:50
|
quote: You did run setup.asp on database after upgrading to the latest version, right? What database type and version are you using?
Sorry, I didn't run the setup, maybe this is the problem but I cannot run the setup because I added many mods...
quote: Would a well-placed cint() bring it back into line - it would fail for the text datatype, so the error could be captured on the following line.
Yes, IMO the Cint or better CLng will do the trick ;-)
quote: Strangeness indeed ... Is this happening consistently for all members?
Yes, this happens with all members
quote: What database type and version are you using?
I'm using MySql, I've aligned my 3.4.04 version to the latest one by comparing/aligning every file by hands.
In each case IMO the actual implementation of functions doUCount() and doULastPost() is dangerous ;-) |
|
|
davide.lorenzi
Starting Member
12 Posts |
Posted - 18 April 2007 : 07:58:00
|
Just tried to run the setup.asp in a local DB but the problem persists
"Setup has finished without errors..." |
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 18 April 2007 : 08:01:48
|
quote: Originally posted by davide.lorenzi Sorry, I didn't run the setup, maybe this is the problem but I cannot run the setup because I added many mods...
Sounds like that could be your problem, so; you need to run the v3.4.06 setup.asp. It won't effect any of the tables or fields added by your mods, only those that relate to the base install of Snitz.
|
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.” |
|
|
davide.lorenzi
Starting Member
12 Posts |
Posted - 18 April 2007 : 08:03:46
|
Good! I'll execute the setup.asp immediately in my online DB but the problem persists ;-) I'll use the modified version of the inc_func_count.asp.
Thank you for your advice! |
|
|
Hermes
Junior Member
Croatia
113 Posts |
|
davide.lorenzi
Starting Member
12 Posts |
Posted - 18 April 2007 : 08:31:54
|
My hosting provider uses the latest MySql version, this should be version 5.0 I think, at home I'm using version 4.0. The problem persists in each version. Thanks! |
|
|
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
|
davide.lorenzi
Starting Member
12 Posts |
Posted - 18 April 2007 : 08:42:17
|
No, the problem occurs for every user |
|
|
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
|
davide.lorenzi
Starting Member
12 Posts |
Posted - 18 April 2007 : 08:49:46
|
Yes ;-) |
|
|
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
|
Topic |
|