the result of calcul with php3 and php4 is different
| From: | Thierry Museux | Date: | Wed, 24 May 2000 23:11:14 +0000 |
| Subject: | the result of calcul with php3 and php4 is different | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-496@lists.php.net to get a copy of this message | ||
i have installed linux rh 6.2 mysql 3.22.32 php3 3.0.16
and the same thing with linux rh 6.2 mysql 3.22.32 php4 4.0.0
i create in the base test a table test with one field named TVA double 16,3
i insert in TVA 0.206
i use this script:
$host="localhost";
$myuser="root";
$mypwd="";
$mydb="test";
$mysql_link=mysql_connect($host,$myuser,$mypwd);
print("mysql_link=$mysql_link<br>\n");
$mysql_db=mysql_select_db($mydb,$mysql_link);
print("mysql_db=$mysql_db<br>");
----connect is ok ----
$query_produits= "SELECT * FROM test";
$mysql_result_produit=mysql_query($query_produits,$mysql_link);
print("mysql_result_produit=$mysql_result_produit<br>");
-- query is OK -----
$TotalRow=mysql_num_rows($mysql_result_produit);
print("TotalRow=$TotalRow<br>");
$row=mysql_fetch_array($mysql_result_produit);
printf("%.3f<br>",$row["TVA"]);
-------- it is displayed 0.206 -------OK
// Calcul ---------------
$var1=100;
$var2=$row["TVA"];
$var3=2;
$var4=gettype($var2);
print("getype=$var4<br>"); it is displayed string
$var5=$row["TVA"]*$var3; ----here is the pb
with PHP3 the result of $var5 is 0.412
with PHP4 the result of $var5 is 0
Where is the problem ???
print("PrixHT=$var1<br>TVA=$var2<br>Qté=$var3<br>total=$var5<br>------------
------------------<br>");
// Calcul ---------------
thierry@museux.com