Jump to content

Decimal operations issues on PHP / IIS 6


gustaav

Recommended Posts

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!

Link to comment
Share on other sites

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"!

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.