gustaav Posted December 9, 2009 Share Posted December 9, 2009 I have a really strange problem!!!! I need urgent help for this! I have a PHP Website running on IIS 6 and there are several operations with decimal variables. The problem is that somehow, the operations with all decimals doesn't work well. It truncates all decimal numbers and because of that, every operations in the site crashes!!! For example if i have $value = 0.0;, if i do the operation $value += 1.75; the variable value when printing would be "1". Other example is when I make comparisons. If i write the if statement if ($value != 0) and the variable value is 0.75... it returns true!!! The rare thing is that all operations works well in the past... about a month ago, this starts to fail! Please I really need help! Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/184537-decimal-operations-issues-on-php-iis-6/ Share on other sites More sharing options...
Mchl Posted December 9, 2009 Share Posted December 9, 2009 Show some code that prints out these values. And 0 is not equal to 0.75 so it should return true. Quote Link to comment https://forums.phpfreaks.com/topic/184537-decimal-operations-issues-on-php-iis-6/#findComment-974208 Share on other sites More sharing options...
gustaav Posted December 9, 2009 Author Share Posted December 9, 2009 Yes, exactly! It should be true, but it returns false! As I said before, this works well before! I don't know why it suddenly stops working! It appears to be variable operation issues... $credits = row['CREDITS']; if($credits==0) echo 'NONE'; else echo $credits; For this code, i assign a value to the $credits variable through a database connection. If the value of the variable is 0.75, it displays "NONE". The strange thing is that if i print the "row['CREDITS']" value it prints "0.75", but if i print the $credits value it prints "0"! Quote Link to comment https://forums.phpfreaks.com/topic/184537-decimal-operations-issues-on-php-iis-6/#findComment-974231 Share on other sites More sharing options...
Mchl Posted December 9, 2009 Share Posted December 9, 2009 Starting with obvious things: there's missing $ before 'row' here $credits = row['CREDITS']; Quote Link to comment https://forums.phpfreaks.com/topic/184537-decimal-operations-issues-on-php-iis-6/#findComment-974243 Share on other sites More sharing options...
gustaav Posted December 9, 2009 Author Share Posted December 9, 2009 Pay no attention of that... of course is "$row", I must accidentally erase the "$". The code would be: $credits = $row['CREDITS']; if($credits==0) echo 'NONE'; else echo $credits; It has to bee a PHP or IIS issue, i tried to reinstall another PHP version, but the problem remains! Would it be a php.ini configuration? Quote Link to comment https://forums.phpfreaks.com/topic/184537-decimal-operations-issues-on-php-iis-6/#findComment-974258 Share on other sites More sharing options...
Mchl Posted December 9, 2009 Share Posted December 9, 2009 Please do: var_dump($row['CREDITS']); Quote Link to comment https://forums.phpfreaks.com/topic/184537-decimal-operations-issues-on-php-iis-6/#findComment-974261 Share on other sites More sharing options...
gustaav Posted December 9, 2009 Author Share Posted December 9, 2009 Ok, I add the code and this is what displays: string(3) ",75" Looking at this it might be regional issues because I'm in Guatemala, it should be displaying ".75" instead ",75" don't you think? Quote Link to comment https://forums.phpfreaks.com/topic/184537-decimal-operations-issues-on-php-iis-6/#findComment-974271 Share on other sites More sharing options...
Mchl Posted December 9, 2009 Share Posted December 9, 2009 Yes it should. I've same problem myself. Use str_replace to change , to . and you should be fine. Quote Link to comment https://forums.phpfreaks.com/topic/184537-decimal-operations-issues-on-php-iis-6/#findComment-974276 Share on other sites More sharing options...
gustaav Posted December 9, 2009 Author Share Posted December 9, 2009 Yes, it really works with str_replace(). It is a regional configuration issue then! Thanks a lot! But, is there another way to change the regional configuration of the website? I'm telling you this because I have several pages with decimal operations and it will take me really long to apply str_replace in all pages... In the other hand, I mentioned before that in the past all pages work fine, so, somehow the regional configuration changed. Quote Link to comment https://forums.phpfreaks.com/topic/184537-decimal-operations-issues-on-php-iis-6/#findComment-974294 Share on other sites More sharing options...
Mchl Posted December 9, 2009 Share Posted December 9, 2009 You might try toying with setlocale Quote Link to comment https://forums.phpfreaks.com/topic/184537-decimal-operations-issues-on-php-iis-6/#findComment-974303 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.