I have a very dumb question that I'm puzzled with. I am creating a script that is
returning tow values from a DB...The values will either be a number or the word
resident so i'm checking for that first...if they are indeed numbers they need to be
added together storing the sum in a variable which will give the total later in the
script. For some reason I keep getting back a very incorrect value when using the
script below:
$total_state_income = 0;
$row['CA_state_source_income'] = "14,133";
$row['GA_state_source_income'] = "Resident";
$row['IL_state_source_income'] = "10,556";
if(!strchr($row['CA_state_source_income'],"Resident"))
{
$total_state_income = $total_state_income +
(int)$row['CA_state_source_income'];
}
if(!strchr($row['GA_state_source_income'],"Resident"))
{
$total_state_income = $total_state_income +
(int)$row['GA_state_source_income'];
}
if(!strchr($row['IL_state_source_income'],"Resident"))
{
$total_state_income = $total_state_income +
(int)$row['IL_state_source_income'];
}
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??
Thanks in advance for your help,
Ron
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php