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

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: Database: MySql
 "Invalid use of group function"
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

Panhandler
Average Member

USA
783 Posts

Posted - 09 February 2007 :  11:30:23  Show Profile  Visit Panhandler's Homepage
I did both a Snitz search and a Google search on this.
It appears to be a database related error. The Google results are way over my head, so. . .

This is from Snitz 3.4.06, MySql db and the Calendar Mod.
Results that I've found are that by removing the code in red (see below) the program Will stop throwing the error.
However, the events list will not be in proper sequence (by date).


Here is the code:

strSql = strSql & _
"GROUP BY T.TOPIC_ID, T.FORUM_ID, T.CAT_ID, T.T_SUBJECT, T.T_AUTHOR, T.T_STATUS, " & _
"E.EVENT_DATE, C.CAT_MODERATION, F.F_MODERATION " & _
"ORDER BY min(E2.EVENT_DATE) Asc, T.TOPIC_ID Asc, E.EVENT_DATE Asc "

Removing the red code will stop the error:
"Invalid use of group function"

You can see it here: Events List
Everything else works.


"5-in-1 Snitz Common Expansion Pack" - five popular mods packaged for easy install
". . .on a mote of dust, suspended in a sunbeam. . ."
HarborClassifieds
Support Snitz Forums


HuwR
Forum Admin

United Kingdom
20600 Posts

Posted - 09 February 2007 :  11:59:34  Show Profile  Visit HuwR's Homepage
I think you will find that when using group, any item in your oder clause must be in the group by, should it be

ORDER BY min(E.EVENT_DATE) rather than (E2.EVENT_DATE) ?
Go to Top of Page

Panhandler
Average Member

USA
783 Posts

Posted - 09 February 2007 :  12:26:07  Show Profile  Visit Panhandler's Homepage
I made the suggested correction:
ORDER BY min(E.EVENT_DATE) rather than (E2.EVENT_DATE)

The same error occurs.
Going to the line number 1155 that the error specifies, it reads:

set rs = Server.CreateObject("ADODB.Recordset")
rs.open StrSql, My_conn


My zero sum knowledge of databases isn't helping any either.


"5-in-1 Snitz Common Expansion Pack" - five popular mods packaged for easy install
". . .on a mote of dust, suspended in a sunbeam. . ."
HarborClassifieds
Support Snitz Forums


Go to Top of Page

JJenson
Advanced Member

USA
2121 Posts

Posted - 09 February 2007 :  13:34:35  Show Profile  Visit JJenson's Homepage
I don't know if this is the case here but usually when have gotten that code its cause I have misplaced some code. Usually it has referred to the active users mod. But like I said I am not sure that applies here just got that same error when that has happend to me. Hope that helps.
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 09 February 2007 :  13:39:26  Show Profile  Send ruirib a Yahoo! Message
Can you post the entire SQL statement?


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

Panhandler
Average Member

USA
783 Posts

Posted - 09 February 2007 :  14:48:42  Show Profile  Visit Panhandler's Homepage
quote:
Originally posted by ruirib

Can you post the entire SQL statement?


If you mean the error code that it is giving, yes:
Microsoft OLE DB Provider for ODBC Drivers error '80040e31'

[MySQL][ODBC 3.51 Driver][mysqld-4.1.19-community-nt]Invalid use of group function

/campfire/cal.asp, line 1155



"5-in-1 Snitz Common Expansion Pack" - five popular mods packaged for easy install
". . .on a mote of dust, suspended in a sunbeam. . ."
HarborClassifieds
Support Snitz Forums


Go to Top of Page

HuwR
Forum Admin

United Kingdom
20600 Posts

Posted - 09 February 2007 :  15:59:39  Show Profile  Visit HuwR's Homepage
no I think he meant can you show us all the code that makes up the sql rather than just the group by part
Go to Top of Page

Panhandler
Average Member

USA
783 Posts

Posted - 09 February 2007 :  16:49:59  Show Profile  Visit Panhandler's Homepage
Ah. . .


'Get the events from the database
strSql = "SELECT T.TOPIC_ID, " & _
"T.FORUM_ID, " & _
"T.CAT_ID, " & _
"T.T_SUBJECT, " & _
"T.T_AUTHOR, " & _
"T.T_STATUS, " & _
"E.EVENT_DATE, " & _
"C.CAT_MODERATION, " & _
"F.F_MODERATION " & _
"FROM (((" & _
strTablePrefix & "TOPICS AS T " & _
"INNER JOIN " & _
strTablePrefix & "CAL_EVENTS AS E ON T.TOPIC_ID = E.TOPIC_ID) " & _
"INNER JOIN " & _
strTablePrefix & "CATEGORY AS C ON T.CAT_ID = C.CAT_ID) " & _
"INNER JOIN " & _
strTablePrefix & "FORUM AS F ON T.FORUM_ID = F.FORUM_ID) " & _
"INNER JOIN " & _
strTablePrefix & "CAL_EVENTS AS E2 ON E.TOPIC_ID = E2.TOPIC_ID "

Select Case strDisplay
Case "future"
strSql = strSql & "WHERE E.EVENT_DATE >= '" & DateToStr(DateValue(strForumTimeAdjust)) & "' "
Case "past"
strSql = strSql & "WHERE E.EVENT_DATE < '" & DateToStr(DateValue(strForumTimeAdjust)) & "' "
end Select

if intRqCalForumID <> 0 then strSQL = strSQL & _
"AND T.FORUM_ID = " & intRqCalForumID & " "

strSql = strSql & _
"GROUP BY T.TOPIC_ID, T.FORUM_ID, T.CAT_ID, T.T_SUBJECT, T.T_AUTHOR, T.T_STATUS, " & _
"E.EVENT_DATE, C.CAT_MODERATION, F.F_MODERATION " & _
"ORDER BY min(E.EVENT_DATE) Asc, T.TOPIC_ID Asc, E.EVENT_DATE Asc "


set rs = Server.CreateObject("ADODB.Recordset")
rs.open StrSql, My_conn




"5-in-1 Snitz Common Expansion Pack" - five popular mods packaged for easy install
". . .on a mote of dust, suspended in a sunbeam. . ."
HarborClassifieds
Support Snitz Forums


Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 09 February 2007 :  17:33:52  Show Profile  Send ruirib a Yahoo! Message
Better add a

Response.Write strSql
Response.End

Just before the line where you have

set rs=...

Then post whatever is shown in the screen.


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

Panhandler
Average Member

USA
783 Posts

Posted - 09 February 2007 :  17:48:44  Show Profile  Visit Panhandler's Homepage
When done as instructed,
It doesn't crash the whole forum/calendar. . .see here
Instead of the "list of events", it shows this code:


SELECT T.TOPIC_ID, T.FORUM_ID, T.CAT_ID, T.T_SUBJECT, T.T_AUTHOR, T.T_STATUS, E.EVENT_DATE, C.CAT_MODERATION, F.F_MODERATION FROM (((FORUM_TOPICS AS T INNER JOIN FORUM_CAL_EVENTS AS E ON T.TOPIC_ID = E.TOPIC_ID) INNER JOIN FORUM_CATEGORY AS C ON T.CAT_ID = C.CAT_ID) INNER JOIN FORUM_FORUM AS F ON T.FORUM_ID = F.FORUM_ID) INNER JOIN FORUM_CAL_EVENTS AS E2 ON E.TOPIC_ID = E2.TOPIC_ID WHERE E.EVENT_DATE >= '20070209000000' GROUP BY T.TOPIC_ID, T.FORUM_ID, T.CAT_ID, T.T_SUBJECT, T.T_AUTHOR, T.T_STATUS, E.EVENT_DATE, C.CAT_MODERATION, F.F_MODERATION ORDER BY min(E.EVENT_DATE) Asc, T.TOPIC_ID Asc, E.EVENT_DATE Asc


"5-in-1 Snitz Common Expansion Pack" - five popular mods packaged for easy install
". . .on a mote of dust, suspended in a sunbeam. . ."
HarborClassifieds
Support Snitz Forums


Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 09 February 2007 :  18:49:09  Show Profile  Send ruirib a Yahoo! Message
I am sorry, but I fail to see the need for using a Group By in that statement, since no aggregate function is used. Why would you group if you don't aggregate?!

What is that page supposed to do?


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

Panhandler
Average Member

USA
783 Posts

Posted - 09 February 2007 :  19:08:21  Show Profile  Visit Panhandler's Homepage
That page is suppossed to take all the calendar events and list them sequentially.
I assume that the as each event is posted in the calendar it goes into the database with some kind of date identifier.
When the "Events List" is clicked, it should retrieve all the calendar events and put them into cronological order, regardless of what order they were posted.

By removing the min(E2.EVENT)DATE) Asc, from the code, the application will retrieve all dates and list them in the order that they were posted! When in fact, they should be listed in the order by which they will occur.

You can see my little test list in it's disordered form with I remove that little bit of min(E2.EVENT)DATE) Asc, here: See Events List


"5-in-1 Snitz Common Expansion Pack" - five popular mods packaged for easy install
". . .on a mote of dust, suspended in a sunbeam. . ."
HarborClassifieds
Support Snitz Forums


Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 09 February 2007 :  19:31:52  Show Profile  Send ruirib a Yahoo! Message
Change the code to this:

'Get the events from the database
strSql = "SELECT T.TOPIC_ID, " & _
                "T.FORUM_ID, " & _
                "T.CAT_ID, " & _
                "T.T_SUBJECT, " & _
                "T.T_AUTHOR, " & _
                "T.T_STATUS, " & _
                "E.EVENT_DATE, " & _
                "C.CAT_MODERATION, " & _
                "F.F_MODERATION " & _
        "FROM (((" & _
            strTablePrefix & "TOPICS AS T " & _
        "INNER JOIN " & _
            strTablePrefix & "CAL_EVENTS AS E ON T.TOPIC_ID = E.TOPIC_ID) " & _
        "INNER JOIN " & _
            strTablePrefix & "CATEGORY AS C ON T.CAT_ID = C.CAT_ID) " & _
        "INNER JOIN " & _
            strTablePrefix & "FORUM AS F ON T.FORUM_ID = F.FORUM_ID) " & _
        "INNER JOIN " & _
            strTablePrefix & "CAL_EVENTS AS E2 ON E.TOPIC_ID = E2.TOPIC_ID "

Select Case strDisplay
    Case "future"
        strSql = strSql & "WHERE E.EVENT_DATE >= '" & DateToStr(DateValue(strForumTimeAdjust)) & "' "
    Case "past"
        strSql = strSql & "WHERE E.EVENT_DATE < '" & DateToStr(DateValue(strForumTimeAdjust)) & "' "
end Select

if intRqCalForumID <> 0 then strSQL = strSQL & _
            "AND T.FORUM_ID = " & intRqCalForumID & " "

strSql = strSql & "ORDER BY E.EVENT_DATE Asc, T.TOPIC_ID Asc"


set rs = Server.CreateObject("ADODB.Recordset")
rs.open StrSql, My_conn


Should do what you want.


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

Panhandler
Average Member

USA
783 Posts

Posted - 09 February 2007 :  19:34:32  Show Profile  Visit Panhandler's Homepage
Never mind. . .I finally got it.
Thanks for making me look, and look, and look.

Simply reversing the
E.EVENT_DATE Asc, T.TOPIC_ID Asc in
"ORDER BY min(E2.EVENT_DATE) Asc, T.TOPIC_ID Asc, E.EVENT_DATE Asc "
and removing the min(E2.EVENT_DATE) Asc solved the problem.

I don't know why it work. . .it just works.


"5-in-1 Snitz Common Expansion Pack" - five popular mods packaged for easy install
". . .on a mote of dust, suspended in a sunbeam. . ."
HarborClassifieds
Support Snitz Forums


Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 10 February 2007 :  04:21:12  Show Profile  Send ruirib a Yahoo! Message
Well you still have the Group By clause that is doing nothing...


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

Panhandler
Average Member

USA
783 Posts

Posted - 10 February 2007 :  09:17:08  Show Profile  Visit Panhandler's Homepage
Okay, I changed the code to that which you listed above and tested it.
The results are some redundancy in the Events List:
See Events List

I'll change it back to what it was later today unless you have something else.


"5-in-1 Snitz Common Expansion Pack" - five popular mods packaged for easy install
". . .on a mote of dust, suspended in a sunbeam. . ."
HarborClassifieds
Support Snitz Forums


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