digitalgod Posted August 25, 2006 Share Posted August 25, 2006 I need to get the sum of 2 query results but it won't let me add them up.Here's what I have[code]<?php$query = mysql_query("SELECT name FROM list WHERE club = '".$row['club']."' AND date = '".$row['date']."'") or die(mysql_error());$count_result = mysql_num_rows($query);$friends_query = mysql_query("SELECT SUM(number) FROM list WHERE club = '".$row['club']."' AND date = '".$row['date']."'") or die(mysql_error());$friends_count = mysql_fetch_array($friends_query);$friends_count = $friends_count + $count_result;?>[/code]and I get this error Fatal error: Unsupported operand types. Link to comment https://forums.phpfreaks.com/topic/18603-adding-up-variables-solved/ Share on other sites More sharing options...
hitman6003 Posted August 25, 2006 Share Posted August 25, 2006 change:[code]$friends_count = mysql_fetch_array($friends_query);[/code]to[code]$friends_count = mysql_result($friends_query, 0);[/code]http://www.php.net/mysql_result Link to comment https://forums.phpfreaks.com/topic/18603-adding-up-variables-solved/#findComment-80136 Share on other sites More sharing options...
digitalgod Posted August 25, 2006 Author Share Posted August 25, 2006 thanks worked perfectly Link to comment https://forums.phpfreaks.com/topic/18603-adding-up-variables-solved/#findComment-80139 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.