Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/O Code)
 Thanks Mod Revisited

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!
Before posting, make sure you have read this topic!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
   

T O P I C    R E V I E W
Carefree Posted - 11 March 2013 : 12:20:54
This has come up a number of times over the years and, as far as I know, nobody has done it. I'd be happy to code it but I'm hitting a mental block as to the best way. Anyone have any suggestions?
15   L A T E S T    R E P L I E S    (Newest First)
Carefree Posted - 07 April 2015 : 16:23:30
Heard that someone experienced an error. Please, either post a link to your "topic.asp" in .txt format for me to see, or reply here and surround your "topic.asp" with [scrollcode][/scrollcode].

Resolved. Had code blocks in wrong place.
Carefree Posted - 03 April 2015 : 22:51:08
Well, no change, still failed. Back to the drawing board.

Redid the routines in "topic.asp" and the "pop_thanks.asp" on SnitzBitz. They will now work with all.
ruirib Posted - 03 April 2015 : 17:44:47
quote:
Originally posted by Carefree

Well, I previously only had group by member_id since that was the only selected field ... that didn't work, same error. So I guess I need to put all three fields in the first select as well as in the distinct select?


Yes, you need to have all three fields in the SELECT clause.The fields are needed in the query that has the GROUP BY clause but here, since you are SELECT from the subquery, the subquery needs the three fields as well, or they wouldn't be in the main query, to start with.

With a single Group By field, and that field present in the SELECT clause, I don't see why the query would fail.
Carefree Posted - 03 April 2015 : 16:57:10
Well, I previously only had group by member_id since that was the only selected field ... that didn't work, same error. So I guess I need to put all three fields in the first select as well as in the distinct select?
ruirib Posted - 03 April 2015 : 13:15:38
In SQL Server, fields in a Group By clause need to be included in the SELECT clause, as well. There are some exceptions to this, but they don't apply to your case.
Carefree Posted - 03 April 2015 : 10:18:13
OK. There's a SQL 'GROUP BY' syntax error on lines 20/50 (in red) below. It works fine with MS Access, but MS SQL gets the hiccups. Can anyone spot a problem?


<!--#INCLUDE FILE="config.asp" -->
<!--#INCLUDE FILE="inc_header_short.asp" -->
<%
'	##	Set value for intReaders below.
	'	0 = Author only
	'	1	= Author, Admins
	'	2 = Author, Admins, Moderators
	'	3	= All members
	'	4 = Anyone

intTYReaders = 1 : intTYAllowed=0
If Request("RID") > "0" Then
	strSqlTY = "SELECT R_AUTHOR FROM " & strTablePrefix & "REPLY WHERE REPLY_ID=" & Request("RID")
	Set rsTY=my_Conn.Execute(strSqlTY)
	If Not rsTY.EOF Then
		intRID=rsTY("R_AUTHOR")
		rsTY.Close
	End If
	Set rsTY = Nothing
	strSqlTY = "SELECT MEMBER_ID FROM (SELECT DISTINCT MEMBER_ID, TOPIC_ID, REPLY_ID FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Request("TID") & " AND REPLY_ID=" & Request("RID") & ") GROUP BY MEMBER_ID, TOPIC_ID, REPLY_ID;"
	Select Case intTYReaders
		Case 0
			If (MemberID = intRID) Then
				Call TYP
			End If
		Case 1
			If (MemberID = intRID) Or (mLev > 2) Then
				Call TYP
			End If
		Case 2
			If (MemberID = intRID) Or (mLev > 1) Then
				Call TYP
			End If
		Case 3
			If (MemberID = intRID) Or (mLev > 0) Then
				Call TYP
			End If
		Case Else
			Call TYP
	End Select
End If
If Request("RID") = "0" Then
	strSqlTY = "SELECT T_AUTHOR FROM " & strTablePrefix & "TOPICS WHERE TOPIC_ID=" & Request("TID")
	Set rsTY=my_Conn.Execute(strSqlTY)
	If Not rsTY.EOF Then
		intTID=rsTY("T_AUTHOR")
		rsTY.Close
	End If
	Set rsTY = Nothing
	strSqlTY = "SELECT MEMBER_ID FROM (SELECT DISTINCT MEMBER_ID, TOPIC_ID, REPLY_ID FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Request("TID") & " AND REPLY_ID=0) GROUP BY MEMBER_ID, TOPIC_ID, REPLY_ID;"
	Select Case intTYReaders
		Case 0
			If (MemberID = intTID) Then
				Call TYP
			End If
		Case 1
			If (MemberID = intTID) Or (mLev > 2) Then
				Call TYP
			End If
		Case 2
			If (MemberID = intTID) Or (mLev > 1) Then
				Call TYP
			End If
		Case 3
			If (MemberID = intTID) Or (mLev > 0) Then
				Call TYP
			End If
		Case Else
			Call TYP
	End Select
End If

Sub TYP
	Set rsTY=my_Conn.Execute(strSqlTY)
	If Not rsTY.EOF Then
		Response.Write	"<table align=""0"" border=""0"" cellpadding=""4"" cellspacing=""0"" bgColor=""" & strPageBGColor & """>" & vbNewLine & _
			"	<tr valign=""middle"">" & vbNewLine
		rsTY.MoveFirst
		intAvatDis=0
		Do While Not rsTY.EOF
			intAvatDis = intAvatDis + 1
			If intAvatDis=5 Then
				intAvatDis = 0
				Response.Write	"</tr><tr valign=""middle"">"
			End If
			Response.Write	"<td align=""center"">"
			strSqlTYM = "SELECT DISTINCT M_NAME FROM " & strMemberTablePrefix & "MEMBERS WHERE MEMBER_ID = " & rsTY("MEMBER_ID")
			Set rsTYM=my_Conn.Execute(strSqlTYM)
			If Not rsTYM.EOF Then
				Response.Write	profilelink(rsTYM("M_NAME"),rsTY("MEMBER_ID"))
				rsTYM.Close
			End If
			Set rsTYM = Nothing
			rsTY.MoveNext
			If Not rsTY.EOF Then
				Response.Write	", "
			Else
				Response.Write	"</td>"
			End If
		Loop
		rsTY.Close
	End If
	Set rsTY=Nothing
	intTYAllowed=1
End Sub
%>
Carefree Posted - 03 April 2015 : 06:10:58
Discovered that screen refreshing can cause thanks counter to increase, so modified code to use "select distinct". Get the update on SnitzBitz.
Carefree Posted - 12 March 2015 : 19:57:30
You don't need to worry about the Thanks_ID. It's not necessary for the mod as it stands now. So auto-increment isn't a factor.
Webbo Posted - 12 March 2015 : 13:20:27
I thought I'd found the problem and that is with the way that the database was set up as MySql apparently doesn`t like Auto Increment unless the column is Primary

However changing the database table 'thanks' to add auto increment resulted in the following error and also the author of the post below the one I chose to 'thank' being thanked ....

quote:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[MySQL][ODBC 5.1 Driver][mysqld-5.1.73-community]Duplicate entry '180108' for key 'PRIMARY'

/forum/topic.asp, line 946




There are three instances where loops are created and they are within the 'Polls' mod code and the 'Active Users' mod code, line 182, 1107 and 1135
Carefree Posted - 11 March 2015 : 20:31:23
You have a loop someplace. It definitely won't do that the way I wrote it. I tested this on a pristine (virgin) Snitz installation and it works perfectly. Look for something like this (surrounding the Thanks code).


For i = 1 to 4

or

Do while

or

Do until
Webbo Posted - 11 March 2015 : 17:48:32
Okay,

starting with a new file and the changes above....

when thanking the initial post in the topic I get the following error in the first reply and no other replies show...

quote:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[MySQL][ODBC 5.1 Driver][mysqld-5.1.73-community]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1

/forum/topic.asp, line 945





Emptying the table (thanks) to start again....

If I 'thank' the first reply in the thread it works

However if I 'thank' the initial post or subsequent replies, whilst they add 1 'thanks' to that it adds a further 4 thanks to the first reply also, and the table in the database looks like this...



Carefree Posted - 11 March 2015 : 17:25:32
Is anyone else running this on a MySQL database? If so, are you experiencing the errors that Webbo has?
Carefree Posted - 11 March 2015 : 17:23:37
The code isn't the same for both sections. One is for topics, the other for replies. This is the 940 block:


         '  ## Thanks Below
         intCnt = 0 : intTY = 0
         strSqlTY = "SELECT * FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Reply_TopicID & " AND MEMBER_ID=" & MemberID & " AND REPLY_ID=" & Reply_ReplyID
         Set rsTY=my_Conn.Execute(strSqlTY)
         If (rsTY.BOF Or rsTY.EOF) And (Reply_MemberID <> MemberID) And (mLev > 0) Then
            If Request("Thanks") > "" Then
               my_Conn.Execute("INSERT INTO " & strTablePrefix & "THANKS (MEMBER_ID, TOPIC_ID, REPLY_ID) VALUES (" & MemberID & ", " & ChkString(Request("TOPIC_ID"), "SQLString") & ", " & ChkString(Request("REPLY_ID"), "SQLString") & ")")
            End If
         Else
            intTY = 1
            rsTY.Close
         End If
         Set rsTY = Nothing
         strSqlTY = "SELECT COUNT(MEMBER_ID) AS CNT FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Reply_TopicID & " AND REPLY_ID=" & Reply_ReplyID
         Set rsTY=my_Conn.Execute(strSqlTY)
         If Not rsTY.EOF Then
            intCnt = rsTY("CNT")
            rsTY.Close
         End If
         Set rsTY = Nothing
         If (Reply_MemberID <> MemberID) And (intTY = 0) And (mLev > 0) Then
            Response.Write "                       <a href=""topic.asp?Thanks=" & MemberID & "&method=" & Request("method") & "&REPLY_ID=" & Reply_ReplyID & "&TOPIC_ID=" & Reply_TopicID & "&FORUM_ID=" & Forum_ID & """>" & getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "</a> <font color=""" & strHiLiteFontColor & """><a style=""text-decoration:none;"" href=""JavaScript:openWindowThanks('pop_thanks.asp?TID=" & Reply_TopicID & "&RID=" & Reply_ReplyID & "')"">" & intCnt & "</a></font>" & vbNewLine
         Else
            Response.Write getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "<font color=""" & strHiLiteFontColor & """><a style=""text-decoration:none;"" href=""JavaScript:openWindowThanks('pop_thanks.asp?TID=" & Reply_TopicID & "&RID=" & Reply_ReplyID & "')"">" & intCnt & "</a></font>" & vbNewLine
         End If
         '  ## Thanks Above


This is the 1380 block:


   '  ## Thanks Below
   intCnt = 0 : intTY = 0
   strSqlTY = "SELECT * FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Request("TOPIC_ID") & " AND MEMBER_ID=" & MemberID & " AND REPLY_ID = 0"
   Set rsTY=my_Conn.Execute(strSqlTY)
   If (rsTY.BOF Or rsTY.EOF) And (TMember_ID <> MemberID) And (mLev > 0) Then
      If (Request("Thanks") > "") And (Request("REPLY_ID")<1) Then
         my_Conn.Execute("INSERT INTO " & strTablePrefix & "THANKS (MEMBER_ID, TOPIC_ID) VALUES (" & MemberID & ", " & ChkString(Request("TOPIC_ID"), "SQLString") & ")")
      End If
   Else
      intTY=1
      rsTY.Close
   End If
   Set rsTY = Nothing
   strSqlTY = "SELECT COUNT(MEMBER_ID) AS CNT FROM " & strTablePrefix & "THANKS WHERE REPLY_ID=0 AND TOPIC_ID=" & TOPIC_ID
   Set rsTY=my_Conn.Execute(strSqlTY)
   If Not rsTY.EOF Then
      intCnt = rsTY("CNT")
      rsTY.Close
   End If
   Set rsTY = Nothing
   If (TMember_ID <> MemberID) And (intTY = 0) And (mLev > 0) Then
      Response.Write "                       <a href=""topic.asp?Thanks=" & MemberID & "&method=" & Request("method") & "&TOPIC_ID=" & Topic_ID & "&FORUM_ID=" & Forum_ID & """>" & getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "</a> <font color=""" & strHiLiteFontColor & """><a style=""text-decoration:none;"" href=""JavaScript:openWindowThanks('pop_thanks.asp?TID=" & Topic_ID & "&RID=0')"">" & intCnt & "</a></font>" & vbNewLine
   Else
      Response.Write getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "<font color=""" & strHiLiteFontColor & """><a style=""text-decoration:none;"" href=""JavaScript:openWindowThanks('pop_thanks.asp?TID=" & Topic_ID & "&RID=0')"">" & intCnt & "</a></font>" & vbNewLine
   End If
   '  ## Thanks Above


When you thank the topic, do you get an error?
Webbo Posted - 11 March 2015 : 16:41:04
Replacing the first block of code resulted in the following error...

quote:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[MySQL][ODBC 5.1 Driver][mysqld-5.1.73-community]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1

/forum/topic.asp, line 948



Replacing both blocks of code with the same caused the thread not to display and the initial post to be replaced with an error
Carefree Posted - 11 March 2015 : 16:24:23
It should work fine the way it is, but it's misbehaving. Replace that block of code with this, maybe MySQL will not hiccup.


         '  ## Thanks Below
         intCnt = 0 : intTY = 0
         strSqlTY = "SELECT * FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Reply_TopicID & " AND MEMBER_ID=" & MemberID & " AND REPLY_ID=" & Reply_ReplyID
         Set rsTY=my_Conn.Execute(strSqlTY)
         If (rsTY.BOF Or rsTY.EOF) And (Reply_MemberID <> MemberID) And (mLev > 0) Then
            If Request("Thanks") > "" Then
               intTID=ChkString(Request("TOPIC_ID"), "SQLString")
               intRID=ChkString(Request("REPLY_ID"), "SQLString")
               strSqlTY = "INSERT INTO " & strTablePrefix & "THANKS (MEMBER_ID, TOPIC_ID, REPLY_ID) VALUES (" & MemberID & ", " & intTID & ", " & intRID & ")"
               my_Conn.Execute(strSqlTY)
            End If
         Else
            intTY = 1
            rsTY.Close
         End If
         Set rsTY = Nothing
         strSqlTY = "SELECT COUNT(MEMBER_ID) AS CNT FROM " & strTablePrefix & "THANKS WHERE TOPIC_ID=" & Reply_TopicID & " AND REPLY_ID=" & Reply_ReplyID
         Set rsTY=my_Conn.Execute(strSqlTY)
         If Not rsTY.EOF Then
            intCnt = rsTY("CNT")
            rsTY.Close
         End If
         Set rsTY = Nothing
         If (Reply_MemberID <> MemberID) And (intTY = 0) And (mLev > 0) Then
            Response.Write "                       <a href=""topic.asp?Thanks=" & MemberID & "&method=" & Request("method") & "&REPLY_ID=" & Reply_ReplyID & "&TOPIC_ID=" & Reply_TopicID & "&FORUM_ID=" & Forum_ID & """>" & getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "</a> <font color=""" & strHiLiteFontColor & """><a style=""text-decoration:none;"" href=""JavaScript:openWindowThanks('pop_thanks.asp?TID=" & Reply_TopicID & "&RID=" & Reply_ReplyID & "')"">" & intCnt & "</a></font>" & vbNewLine
         Else
            Response.Write getCurrentIcon(strIconThanks,"Thanks","align=""absmiddle"" hspace=""6""") & "<font color=""" & strHiLiteFontColor & """><a style=""text-decoration:none;"" href=""JavaScript:openWindowThanks('pop_thanks.asp?TID=" & Reply_TopicID & "&RID=" & Reply_ReplyID & "')"">" & intCnt & "</a></font>" & vbNewLine
         End If
         '  ## Thanks Above

Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.13 seconds. Powered By: Snitz Forums 2000 Version 3.4.07