> $row['CA_state_source_income'] = "14,133"; > $row['IL_state_source_income'] = "10,556";
> When I check the value of $total_state_income it equals 24 not the expected 24,689. > The datatype of the values returned from SQL Server are Varchar so I tried > typecasting the values to integers before adding them to the running total. > > What am I doing wrong?? Try this and see what happend: declare @Char2Int1 varchar(8) declare @Char2Int2 varchar(8) select @Char2Int1 = "14,133" select @Char2Int2 = "10,556" select convert(int, stuff(@Char2Int1, charindex(',', @Char2Int1, 1), 1, null)), convert(int, stuff(@Char2Int2, charindex(',', @Char2Int2, 1), 1, null)) If you try this: select convert(int, @Char2Int1), convert(int, @Char2Int2) It will generate an error since the convert function gets confused by the comma. If you have bigger numbers like: 1,234,567 then you need to do the below with each string that might contain a comma: select @nPos = charindex(',', @Char2Int1, 1) while (@nPos > 0) begin select @Char2Int1 = stuff(@Char2Int1, @nPos, 1, null) select @nPos = charindex(',', @Char2Int1, 1) end this will wash away all commas from a string. -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php