[ciapug] strange php/mysql result

Dave J. Hala Jr. dave at 58ghz.net
Tue Jan 22 11:14:44 CST 2008


I've got this table... I sum a couple of columns and return the
results. 

Here's the query and the code:

$sql8="
SELECT sum(csbg_gender.a) as a,sum(csbg_gender.b) as
b,sum(csbg_gender.c) as c FROM table,csbg_gender
WHERE csbg_gender.actv='Y' AND table.id = csbg_gender.served_id";
	$result8 = mysql_query($sql8,$connection) or die(mysql_error());
   	  $csbg_gender = mysql_fetch_array($result8);

When I do:

$x = array_sum($csbg_gender)

The result is exactly 2x the value. Print_f tells me this:

Array ( [0] => 1757 [a] => 1757 [1] => 2142 [b] => 2142 [2] => 35 [c] =>
35 )

I don't understand where the elements [0],[1],[2] came from. Is there a
way to get mysql_fetch_array to return the array without the 0,1,2
elements?

I'm running php 5 on rhel5 and using mysql 4.1

:) Dave


 








More information about the ciapug mailing list