Ok so I never encountered this problem before and a google search didnt really help me either. Before going into the problem you should know I encountered this using a local Wamp server. I tried to multiply some simply numbers and somehow PHP automatically rounds the result to a full digit, while I need at least 2 digits. $total = $price * $ordered; PHP: Price is 9,95 and ordered is 1. It outputs 9 as answer ..... I allready tried this without success (same output): $total = round($price * $ordered, 2); PHP: Its also weird that it round it down instead of up. Maybe its a phpconfig issue ? Please help me !
Maybe you just need to replace comma with dot? I mean: $total = round(str_replace(',','.',$price) * $ordered, 2); PHP:
I dont use WAMP, but this must be part of your problem. If you cast them as floats, does this get around your issue? <?php (float) $price = 9.95; (float) $ordered = 1; (float) $total = $price * $ordered; print $total; ?> PHP:
No im afraid the problem lies deeper then that. I tried that but without a good result. See when I simply echo the numbers from the database it also outputs them as: 9 instead of 9,95 while it is correct in the database, and between calling them from the database and echoing them nothing happens to it .... EDIT: Its getting weirder, sometimes it echos it as 9 and now I noticed it sometimes echos it as 9,95 ...
I did, but it outputs exactly the same because $price turns out to be 9 instead of 9,95 ... Thats the weird thing, I get the info from a database and in there it is 9,95 but as soon as I put it in a string it becomes 9 ....