Page 1 of 1

[SOLVED] sum()

Posted: Sat Jun 19, 2004 3:31 pm
by CerIs
Is the result of a sum query put into the var of that column? Ive been trying this for a while and its not outputting anything:

Code: Select all

<?php 
		  
mysql_pconnect("localhost","User","Pass");
mysql_select_db("douple_Newdata");

		  
$query = "SELECT sum(Downloads) from affmembers";
$result = mysql_query($query)
       or die ("Couldn't execute query.");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
extract($row);

		  
echo "$Downloads";
?>
Thanks

Posted: Sat Jun 19, 2004 4:26 pm
by tim
as always

to troubleshoot any code where you use mysql, add some

or die(mysql_error()); to anything MySQL related.

use error reporting, you will seee whats wrong w/ your code.

:wink:

Posted: Sat Jun 19, 2004 4:34 pm
by Weirdan
heh, just modify your query to look like:

Code: Select all

SELECT sum(Downloads) as Downloads from affmembers
tim is right though, it's much more useful to have mysql_error(), error reporting and so on on development server.

Posted: Sun Jun 20, 2004 5:16 am
by CerIs
Thanks