mysql query with SUM

From: Date: Wed, 17 Oct 2001 19:23:49 +0000
Subject: mysql query with SUM
Groups: php.general 
Request: Send a blank email to php-general+get-71383@lists.php.net to get a copy of this message
I have a database table with whole numbers in a column. Im trying to get the script to add up these numbers by using 'sum' in the sql query. It works correctly from mysql command line. For some reason I cannot echo it out using php. What am I doing wrong.... ----------------------------------------------------------------- <?php /* Attempt to corrctly syncronize the counter table */ include("db.php"); mysql_connect($dbhost, $dbuname, $dbpass); mysql_select_db($dbname); echo "TEST<br>"; $query = "SELECT SUM(count) FROM counter WHERE type = 'cars'"; $result = mysql_query($query); $c = mysql_result($result, 0); echo "$c"; ?>

« previous php.general (#71383) next »