Click to See Complete Forum and Search --> : [RESOLVED] Parsing Variables as Decimals


bulgarian388
03-08-2007, 07:28 PM
Hi dudes, I have a MySQL database that contains a "balance" field. I'm trying to pull out the value and do a conditional statement, but it's not working because PHP is treating the value as a string, but I need it to be a decimal. How do I go about converting the value to decimal so I can do my conditional statement.

Thanks in advance!

jasonahoule
03-08-2007, 07:35 PM
You should be able to do whatever you want to the variable. PHP variables are not typed. You can do the following and it would not cause a problem.

$myVar = "string";
$myVar = 3;

There must be something else to it. Can you post a sample of your code?

NogDog
03-08-2007, 08:44 PM
It could be an issue if the condition is using one of the "identical" operators ("===" or "!=="). Perhaps you need to cast the value using (int) of (float), but it's hard to say without seeing any code or otherwise understanding the specific situation.

bulgarian388
03-10-2007, 03:52 AM
Hey guys, thanks for posting. Well, I don't know what I did but it works now for some reason. I think I just fired up a false alarm cuz I was getting frustrated, but thanks for the help anyway!