It looks like the comma (',') is in this case interpreted as the decimal separator, not (as you apparently suppose) the grouping separator. >> You have a difference in the "locale" between your SQL Server and PHP. You might want to try getting e.g. 14.133,00 (to the cent) or tell PHP to use 14,133.00 See setlocale() and localeconv() and related in the docs. -- Sven
> -----Ursprüngliche Nachricht----- > Von: Herhuth, Ron [SMTP:[EMAIL PROTECTED] > Gesendet am: Dienstag, 25. März 2003 15:46 > An: [EMAIL PROTECTED] > Betreff: [PHP-WIN] Simple Addition issue > > > 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 -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php