From:             [EMAIL PROTECTED]
Operating system: Windows
PHP version:      4.3.0
PHP Bug Type:     Unknown/Other Function
Bug description:  number_function

I got this code from a book. It works as long as the total is less than
999. when it exceeds 999, it can't calculate the total properly. I think
it has something to do with the number_function.  


+++++++++++++++++++++index.html ++++++++++++++++++

<form action="processorder.php" method=post>
<table border=0>

<tr bgcolor=#cccccc>
  <td width=150>Item</td>
  <td width=15>Quantity</td>
</tr>

<tr>
  <td>Tires</td>
  <td align=center><input type="text" name="tireqty" size=3
maxlength=3></td>
</tr>

<tr>
  <td>Oil</td>
  <td align=center><input type="text" name="oilqty" size=3
maxlength=3></td>
</tr>

<tr>
  <td>Spark Plugs</td>
  <td align=center><input type="text" name="sparkqty" size=3
maxlength=3></td>
</tr>

<tr>
  <td colspan=2 align=center><input type=submit value="Submit
Order"></td>
</tr>
</table>
</form>


++++++++++++ preprocess.php ++++++++++++++++++

<html>
<head>
  <title>Jim's Auto Parts - Order Results</title>
</head>
<body>
<h1>Jim's Auto Parts</h1>
<h2>Order Results</h2>

<?
  define("TIREPRICE", 100);
  define("OILPRICE", 10);
  define("SPARKPRICE", 4);
  
  
  echo "<p>Order Processed at ";
  echo date("H:i, jS F");
  echo "<br>";
  echo "<p>Your order is as follows:";
  echo "<br>";
  echo $tireqty." tires<br>";
  echo $oilqty." bottles of oil<br>";
  echo $sparkqty." spark plugs<br>";
  
  $totalqty = $tireqty + $oilqty + $sparkqty;
  $totalamount = $tireqty  * TIREPRICE
               + $oilqty   * OILPRICE
               + $sparkqty * SPARKPRICE;
  $totalamount = number_format($totalamount,2);
  echo "<br>\n";
  echo "Items Ordered:      ".$totalqty."<br>\n";
  echo "Subtotal:           $".$totalamount."<br>\n";
  $taxrate = 0.10;
  $totalamount = $totalamount * (1 + $taxrate);
  $totalamount = number_format($totalamount, 2);
  echo "Total including tax: $".$totalamount."<br>\n";

?>

</body>
</html>
-- 
Edit bug report at http://bugs.php.net/?id=22240&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=22240&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=22240&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=22240&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=22240&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=22240&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=22240&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=22240&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=22240&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=22240&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=22240&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22240&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=22240&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=22240&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=22240&r=gnused

Reply via email to