ERuiz Posted January 10, 2007 Share Posted January 10, 2007 I have the following problem:[code]$sqlfield13 = "SELECT field13 FROM vb3_userfield WHERE userid = '".$IDPilot."' ";$Resultfield13 = $MyDb->f_ExecuteSql($sqlfield13);$PrevHours = $MyDb->f_GetRecord($Resultfield13);$PrevHours = $PrevHours['field13'];$PrevHours = number_format($PrevHours); if ($PrevHours >= 100) { $PrevHours = 50; } else { $PrevHours = 0; }[/code]In the case above, I get the following results:if field13 = 234.3 then $PrevHours = 50if field13 = 72.3 then $PrevHours = 0if field13 = 1,023.3 then $PrevHours = 0How come the last situation is giving the wrong result?Regards,ERuiz Link to comment https://forums.phpfreaks.com/topic/33558-not-recognizing-commas-in-numbers/ Share on other sites More sharing options...
JasonLewis Posted January 10, 2007 Share Posted January 10, 2007 why must you insert the comma's in the first place? Link to comment https://forums.phpfreaks.com/topic/33558-not-recognizing-commas-in-numbers/#findComment-157150 Share on other sites More sharing options...
Jessica Posted January 10, 2007 Share Posted January 10, 2007 number_format is only for when you need to print them out or turn them into strings. If you want to keep doing math with a number (or do comparisons in which it is a number), no commas allowed. Don't use number_format up there. Link to comment https://forums.phpfreaks.com/topic/33558-not-recognizing-commas-in-numbers/#findComment-157152 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.