PHP - SUM function problem - Asked By Olusegun A. on 04-Aug-10 05:39 AM

Hello friends,

am having problem with my SUM function. I tried summing up some figures in a column but is not returning the total of the figures. this is my syntax



$creditbal=mysql_query("SELECT SUM($column), FROM $table WHERE status='P'");


echo $creditbal;


but is not echoing any out any, what can i do.


Ken Fitzpatrick replied to Olusegun A. on 04-Aug-10 05:42 AM

Remove the comma between SUM($column) and FROM. That is causing it to fail.

Super Man replied to Olusegun A. on 04-Aug-10 05:47 AM
you should have to write query like this:

you don't need to write comma after column.

SELECT SUM($column) FROM $table WHERE status='P'"