473,396 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

invalid use of group function

18
Hi,

I have some php scripts to use with a mysql database. I've tested them locally on my computer and they work fine, but when I put them on line I get the message "Invalid use of group function". Here are the group function statements:
Expand|Select|Wrap|Line Numbers
  1. $query = 'SELECT id, name, total FROM totals where id IN(select max(id) from totals group by name) ORDER BY total DESC ';
  2.  
  3. $query = 'SELECT name, SUM(total) AS numtotal FROM totals group by name order by sum(total) desc';
  4.  
Any ideas why they won't work on line will be greatly appreciated!!

Thanks, Tom
Aug 12 '07 #1
7 4284
kovik
1,044 Expert 1GB
"Invalid use of group function"
Wha...? You sure that's an SQL error? What does it say exactly?
Aug 12 '07 #2
pbmods
5,821 Expert 4TB
Heya, Tom.

Which query is generating that error?
Aug 12 '07 #3
Atli
5,058 Expert 4TB
Is it possible that the online server is running an ancient version of MySQL?
Aug 12 '07 #4
tom_b
18
Hi,

I'm not sure which of the statements is generating the error. When I get to that point the only thing on the page are the words "Invalid use of group function". The Mysql version is 4.1.14. Thanks for you time.

Tom
Aug 12 '07 #5
pbmods
5,821 Expert 4TB
Heya, Tom.

Ok. Try this:
Expand|Select|Wrap|Line Numbers
  1. $query = 'SELECT id, name, total FROM totals where id IN(select max(id) from totals group by name) ORDER BY total DESC ';
  2.  
  3. mysql_query($query);
  4. echo $query, '<br />', mysql_error(), '<br /><br />';
  5.  
  6. $query = 'SELECT name, SUM(total) AS numtotal FROM totals group by name order by sum(total) desc';
  7.  
  8. mysql_query($query);
  9. echo $query, '<br />', mysql_error(), '<br /><br />';
  10.  
Aug 12 '07 #6
tom_b
18
Hi,

When I ran the queries through phpMyAdmin the first one worked fine, the second one generated this error;

#1111 - Invalid use of group function

Thanks, Tom
Aug 12 '07 #7
pbmods
5,821 Expert 4TB
This issue has been solved in the MySQL forum. The post is here:
http://www.thescripts.com/forum/thread691615.html

Further posts should be directed to that thread. This thread will now be closed.
Aug 12 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Shino | last post by:
Hi, Can anyone help with this error: "ORA-00904: invalid column name"? Thanks! SQL> create view PPFa as 2 SELECT L.UserID AS LecID, U.Name, U.Email, I.IntakeID, S.UserID AS StudID 3 FROM...
1
by: j.mandala | last post by:
I have a memo field in an appointment application that stores session notes for group psychotherapy sessions. Each attendee of the group has an appointment record. I want to be able to write a...
5
by: Stewart | last post by:
Hi there, I would like to calculate a person's age in years (between 2 dates). I am using the following function for this calculation (source: http://www.mvps.org/access/datetime/date0001.htm)...
2
by: none | last post by:
Hi, I'm opening a popup window with JavaScript. It has a command button. This is from the primary source (opener) window: ###################################################################...
5
by: Matt | last post by:
I am receiving the following error from the simple script below. This works fine from a .NET form but when I access the dll from a Classic ASP page it fails. Microsoft VBScript runtime error...
4
by: c language | last post by:
Hi All, I have written a C++ program, it can be compiled (in UNIX) but when I run it, I usually gives the following errors: free(): invalid pointer 0x51d4a0! free(): invalid pointer 0x51d460!...
7
by: jknaty | last post by:
I'm trying to create a function that splits up a column by spaces, and I thought creating a function that finds the spaces with CHARINDEX and then SUBSTRING on those values would an approach. I...
8
by: tom_b | last post by:
Hi, I'm not really sure if this is a PHP or Mysql issue, but I need some help!! I have some php scripts to use with a mysql database. I've tested everything locally on my computer and they...
2
by: Barry | last post by:
The problem brought by one earlier post from comp.lang.c++ http://groups.google.com/group/comp.lang.c++/browse_thread/thread/bf636c48b84957b/ I take part of the question and reproduce the code to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.