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. Quote 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 Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/18603-adding-up-variables-solved/#findComment-80139 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.