Jump to content

Archived

This topic is now archived and is closed to further replies.

digitalgod

adding up variables *SOLVED*

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.