Re: odd addition error<>?
| From: | callen | Date: | Wed, 16 Aug 2000 18:26:54 +0000 |
| Subject: | Re: odd addition error<>? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-12091@lists.php.net to get a copy of this message | ||
>David Robley wrote:
>
> On 15 Aug, callen wrote:
> > Joao Prado Maia wrote:
>
> Somebody already mentioned, or hinted, that everything returned from
> your database is treated as a string by PHP, so you may have to cast
> some variables to integer or real.
>
> Also you might try checking the type of the offending variables at
> selected spots to see if that is indeed part of the problem.
>
> And, as a last resort, is it possible that there is white space in any
Thanks for the suggestions. Before I slept last night this was the last
thing I remember thinking about. I need to cast $fee to a double!!
This works:
if ( ereg ( "^(<\!TotalCharges>)([0-9]{1,4})(\.)([0-9]{1,})", $buffer,
$regs))
{
$fee .=$regs[2]; // Tens or hundreds column
$fee .=$regs[3]; // decimal point
$fee .=$regs[4]; // Cents
echo "$fee"; // 3.17
}
If I use $fee=$regs[0]; It doesn't.
If $fee actually houses a string of "3.17" why wouldnt that convert when
I add it to $sh ($sh += $fee;) ??
like:
$sh += "3.17"
The manual has an example:
$foo = 1 + "10.5"; // $foo is double (11.5)
What kinda of string conversion is happening to get a result of $sh = 0;
??? Is this because no conversion took place as per unix strtod?
Thanks all for the help!
--
Christopher C.M. Allen
http://design.driver8.org/
Email: callen@driver8.org