Neil Thompson
asked on
cannot get $totCost = $row['totals'] * 0.09; to return a value
Hi
I have a row coming back from my database that I need to be able to multiply and write.
If I just echo $row['totals'] --------------------> I get 123
If I echo $row['totals'] * 0.09; ----> I get 0
How can I get the row value to multiply?
Neil
I have a row coming back from my database that I need to be able to multiply and write.
If I just echo $row['totals'] --------------------> I get 123
If I echo $row['totals'] * 0.09; ----> I get 0
How can I get the row value to multiply?
Neil
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Apologies, and thanks... it did work 100%, had a damn } hiding off the side of the page meaning I was putting the code outside the loop.
Neil
Neil
thanks a lot :)
You're welcome. At least as of now you know how to debug these things. Trace what happens to the variable from it's original state until it gets converted to a numeric and becomes an operand and finally check the result. This way you can find out what happens "wrong" on it's way from being $row['totals'] to becoming a float operand.
ASKER
thanks rohypnol, I always bookmark little snippits like yours, they always come in handy!
Cheers
Neil
Cheers
Neil
Open in new window