Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 08-10-2009, 04:39 AM Left Join Sum Error
evans123's Avatar
Ultra Talker

Posts: 468
Trades: 0
PHP Code:
$sql2 mysql_fetch_array(mysql_query("SELECT manager__playing.player_id, manager__playing.team_id, manager__playing.status, SUM(manager__players.rating) AS rating FROM manager__playing LEFT JOIN manager__players ON manager__playing.player_id = manager__players.player_id WHERE manager__playing.current_position >= '1' && manager__playing.current_position <= '" . ($away_formation['defender'] + 1) . "' && manager__playing.status != '4' && manager__playing.match_id = '" $match_id "' && manager__playing.team_id = '" $away_team "'")); 
I want to return the sum of the manager__players.rating, however when i use the SUM(manager__players.rating) i get this error:

PHP Code:
Warning:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/championshipfl/**/**/match/match2.php on line 199 
Anyone no why?

Last edited by evans123; 08-10-2009 at 04:41 AM..
evans123 is offline
Reply With Quote
View Public Profile Visit evans123's homepage!
 
 
Register now for full access!
Old 08-10-2009, 06:15 AM Re: Left Join Sum Error
EdB
Skilled Talker

Posts: 79
Name: Ed Barnett
Trades: 0
Quote:
Originally Posted by evans123 View Post
PHP Code:
$sql2 mysql_fetch_array(mysql_query("SELECT manager__playing.player_id, manager__playing.team_id, manager__playing.status, SUM(manager__players.rating) AS rating FROM manager__playing LEFT JOIN manager__players ON manager__playing.player_id = manager__players.player_id WHERE manager__playing.current_position >= '1' && manager__playing.current_position <= '" . ($away_formation['defender'] + 1) . "' && manager__playing.status != '4' && manager__playing.match_id = '" $match_id "' && manager__playing.team_id = '" $away_team "'")); 
I want to return the sum of the manager__players.rating, however when i use the SUM(manager__players.rating) i get this error:

PHP Code:
Warning:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/championshipfl/**/**/match/match2.php on line 199 
Anyone no why?
From my experience you need to use a "GROUP BY" clause to use the SUM() function. At the end of your query try adding;

GROUP BY manager__players.player_id

This will return the SUM of the rating for each player (one would hope anyway)
__________________

Please login or register to view this content. Registration is FREE
EdB is offline
Reply With Quote
View Public Profile Visit EdB's homepage!
 
Old 08-11-2009, 05:49 AM Re: Left Join Sum Error
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Maybe the query doesn't do exactly what you intended, but there doesn't seem to be any errors in it. Since the error message says it is the argument being passed to mysql_fetch_array() that is invalid, that is, the result from mysql_query(). The mysql_query() function itself seem to be executed properly. Perhaps no rows are returned?
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Reply     « Reply to Left Join Sum Error
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.24914 seconds with 12 queries