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 MOD-Group
 MOD Add-On Forum (W/Code)
 Decrease members post count on post deletion
 New Topic  Reply to Topic
 Printer Friendly
Previous Page
Author Previous Topic Topic Next Topic
Page: of 4

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 22 April 2008 :  15:51:03  Show Profile  Send ruirib a Yahoo! Message  Reply with Quote
Yeah, that figures. MyBadSQL!<


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

modifichicci
Average Member

Italy
787 Posts

Posted - 23 April 2008 :  14:47:03  Show Profile  Visit modifichicci's Homepage  Reply with Quote
Well, to bypass the problem I have tryed this solution:

instead of ruirib's query, i have put
strUpLastPost = Reply_Autore
DataUltimoPost = getultimopost(strUpLastPost)

and created the function

function getultimopost(strUpLastPost)
strSql = "SELECT MAX(T_DATE) AS T_VALUE FROM " & strTablePrefix & "TOPICS  WHERE T_AUTHOR = " & strUpLastPost
set rs = my_Conn.Execute (strSql)
if not(rs.eof or rs.bof) then
DataUltimoPostT = rs("T_VALUE")
else
DataUltimoPostT = ""
end if
rs.close
set rs = nothing
strSql = "SELECT MAX(R_DATE) AS T_VALUE FROM " & strTablePrefix & "REPLY  WHERE R_AUTHOR = " & strUpLastPost
set rs = my_Conn.Execute (strSql)
if not(rs.eof or rs.bof) then
DataUltimoPostR = rs("T_VALUE")
else
DataUltimoPostR = ""
end if
rs.close
set rs = nothing
strSql = "SELECT MAX(R_DATE) AS T_VALUE FROM " & strTablePrefix & "A_REPLY  WHERE R_AUTHOR = " & strUpLastPost
set rs = my_Conn.Execute (strSql)
if not(rs.eof or rs.bof) then
DataUltimoPostRA = rs("T_VALUE")
else
DataUltimoPostRA = ""
end if
rs.close
set rs = nothing
strSql = "SELECT MAX(T_DATE) AS T_VALUE FROM " & strTablePrefix & "A_TOPICS  WHERE T_AUTHOR = " & strUpLastPost
set rs = my_Conn.Execute (strSql)
if not(rs.eof or rs.bof) then
DataUltimoPostTA = rs("T_VALUE")
else
DataUltimoPostTA = ""
end if
rs.close
set rs = nothing
if DataUltimoPostT > DataUltimoPostR then
	DUpost = DataUltimoPostT
else
	DUpost = DataUltimoPostR
end if

if DataUltimoPostTA > DataUltimoPostRA then
	DUpostA = DataUltimoPostTA
else
	DUpostA = DataUltimoPostRA
end if
if DUpost > DUpostA then
 	getultimopost = DUpost
 else
 	getultimopost = DUpostA
end if

end function


no error now.. but.. it worked once with admin and then it get a null value for last post date..
I think there is a logical error in my routine, but i cannot find it and maybe there is a better way to find the max value of four, but I am a surgeon and this is a pure hobby, so if someone can give me some advices he is welcome.. <

Ernia e Laparocele
Forum di Ernia e Laparocele
Acces - MySql Migration Tutorial
Adamantine forum
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 23 April 2008 :  15:26:27  Show Profile  Send ruirib a Yahoo! Message  Reply with Quote
You will need to test for Null value, since if the user has no posts, max(t_Date) will return a null value. So, test for NULL and if the date is null, set the value for the last post date to ''.<


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

modifichicci
Average Member

Italy
787 Posts

Posted - 23 April 2008 :  15:35:14  Show Profile  Visit modifichicci's Homepage  Reply with Quote
that isn't done by bof and eof?<

Ernia e Laparocele
Forum di Ernia e Laparocele
Acces - MySql Migration Tutorial
Adamantine forum
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 23 April 2008 :  15:39:50  Show Profile  Send ruirib a Yahoo! Message  Reply with Quote
No, because there will be a record, with a single column, but that column will have a null value.<


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

modifichicci
Average Member

Italy
787 Posts

Posted - 23 April 2008 :  16:35:42  Show Profile  Visit modifichicci's Homepage  Reply with Quote
I have checked the dates
with
if DataUltimoPostR > DataUltimoPostRA then
response.write "DataUltimoPostR" & DataUltimoPostR
else
response.write "Dati non corrispondenti"
end if
response.write "DataUltimoPostT" & DataUltimoPostT
response.write "DataUltimoPostRA" & DataUltimoPostRA
response.write "DataUltimoPostTA" & DataUltimoPostTA

and dates are selected correctly, and when there is no reply or topics from the author the value is null.
But the if statement
if DataUltimoPostR > DataUltimoPostRA then
with DataUltimoPostR = 20080423223022
and DataUltimoPostRA = "" isn't verify and I get always "Dati non corrispondenti"
near the goal but so far..




<

Ernia e Laparocele
Forum di Ernia e Laparocele
Acces - MySql Migration Tutorial
Adamantine forum

Edited by - modifichicci on 23 April 2008 16:36:34
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 23 April 2008 :  18:19:49  Show Profile  Send ruirib a Yahoo! Message  Reply with Quote
A null date is not comparable, you need to test it with IsNull(DataUltimoPostRA) or whatever variable you want to test for Null.<


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

modifichicci
Average Member

Italy
787 Posts

Posted - 25 April 2008 :  05:30:18  Show Profile  Visit modifichicci's Homepage  Reply with Quote
I think I have solved:
here is the new pop_delete.asp

pop_delete.asp

I have changed the function to:

function getultimopost(strUpLastPost)
strControllo = "00000000000000"
strSql = "SELECT MAX(T_DATE) AS T_VALUE FROM " & strTablePrefix & "TOPICS WHERE T_AUTHOR = " & strUpLastPost
set rs = my_Conn.Execute (strSql)
if not(rs.eof or rs.bof) then
DataUltimoPostT = trim(rs("T_VALUE"))
if IsNull(DataUltimoPostT) then DataUltimoPostT = strControllo
else
DataUltimoPostT = strControllo
end if
rs.close
set rs = nothing
strSql = "SELECT MAX(R_DATE) AS T_VALUE FROM " & strTablePrefix & "REPLY WHERE R_AUTHOR = " & strUpLastPost
set rs = my_Conn.Execute (strSql)
if not(rs.eof or rs.bof) then
DataUltimoPostR = trim(rs("T_VALUE"))
if IsNull(DataUltimoPostR) then DataUltimoPostR = strControllo
else
DataUltimoPostR = strControllo
end if
rs.close
set rs = nothing
strSql = "SELECT MAX(R_DATE) AS T_VALUE FROM " & strTablePrefix & "A_REPLY WHERE R_AUTHOR = " & strUpLastPost
set rs = my_Conn.Execute (strSql)
if not(rs.eof or rs.bof) then
DataUltimoPostRA = trim(rs("T_VALUE"))
if IsNull(DataUltimoPostRA) then DataUltimoPostRA = strControllo
else
DataUltimoPostRA = strControllo
end if
rs.close
set rs = nothing
strSql = "SELECT MAX(T_DATE) AS T_VALUE FROM " & strTablePrefix & "A_TOPICS WHERE T_AUTHOR = " & strUpLastPost
set rs = my_Conn.Execute (strSql)
if not(rs.eof or rs.bof) then
DataUltimoPostTA = trim(rs("T_VALUE"))
if IsNull(DataUltimoPostTA) then DataUltimoPostTA = strControllo
else
DataUltimoPostTA = strControllo
end if
rs.close
set rs = nothing
if StrComp(DataUltimoPostT, DataUltimoPostR) = 1 then
DUpost = DataUltimoPostT
else
DUpost = DataUltimoPostR
end if

if StrComp(DataUltimoPostTA, DataUltimoPostRA) = 1 then
DUpostA = DataUltimoPostTA
else
DUpostA = DataUltimoPostRA
end if
if StrComp(DUpost, DUpostA) = 1 then
getultimopost = DUpost
else
getultimopost = DUpostA
end if
if getultimopost = strControllo then getultimopost = ""
end function


and changed the Ruirib routine to

strUpLastPost = Reply_Autore ' or Topic etc in different section
DataUltimoPost = getultimopost(strUpLastPost)
strSql = "UPDATE " & strMemberTablePrefix & "MEMBERS "
strSql = strSql & " SET M_LASTPOSTDATE = '" & DataUltimoPost & "'" 
strSql = strSql & " WHERE MEMBER_ID = " & strUpLastPost
 my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords


If someone knows how to optimize the function, he is welcome.<

Ernia e Laparocele
Forum di Ernia e Laparocele
Acces - MySql Migration Tutorial
Adamantine forum
Go to Top of Page

natty
Starting Member

United States
31 Posts

Posted - 27 April 2008 :  22:43:15  Show Profile  Reply with Quote
very nice<

-------------------
http://www.sumwebdesign.com
http://www.tppsych.net
Go to Top of Page
Page: of 4 Previous Topic Topic Next Topic  
Previous Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000 Version 3.4.07