logo       

AW: Simple Addition issue: msg#00346

Subject: AW: Simple Addition issue
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:Ron.Herhuth@xxxxxxxxxxxx]
> Gesendet am:  Dienstag, 25. März 2003 15:46
> An:   php-windows@xxxxxxxxxxxxx
> 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




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe