basic: sum() only zeros
Posted: Wed Apr 06, 2005 12:37 am
Hey everybody-
thanks in advance for all the help lately. Here's the situation. I have a table, with a column named "minutes." The fields are set as integer, not null, default value of 0. I am using mysql_query sum() to add all values of that column together obviously. The column is filled with only zeros, and when I try to run the sum() query, php gives me the blank screen, no error messages or anything. If I add in a value of 1, 2, 3...whatever to that column via html form, it works fine. but if the column is filled with all zeros, it doesn't work. Hypothetically, I need the column to stay as all zeros until the user changes it. On the code below, assume all db_connect code, etc. is applied...
Thanks again.
thanks in advance for all the help lately. Here's the situation. I have a table, with a column named "minutes." The fields are set as integer, not null, default value of 0. I am using mysql_query sum() to add all values of that column together obviously. The column is filled with only zeros, and when I try to run the sum() query, php gives me the blank screen, no error messages or anything. If I add in a value of 1, 2, 3...whatever to that column via html form, it works fine. but if the column is filled with all zeros, it doesn't work. Hypothetically, I need the column to stay as all zeros until the user changes it. On the code below, assume all db_connect code, etc. is applied...
Code: Select all
<?php
$getallminutes = mysql_query("SELECT SUM(minutes) AS totalminutes FROM table_1 WHERE name='$name'")
or die(mysql_error());
$currentminutes = mysql_result($getallminutes, minutes, 0)
or die(mysql_error());
<?